help with a 'while read' loop to change the names of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with a 'while read' loop to change the names of files
Prev   Next
# 1  
Old 03-01-2008
help with a 'while read' loop to change the names of files

Hi,

I am new to scripting, so any help on this would be much appreciated.

I am trying to rename a bunch of files, taking the names sequentially from a list read in another file...

# ls oldnames
file_1
file_2
file_3

# cat names
red
yellow
green


I want the files to take on the names red yellow green as they are read line by line from the file "names"
ie
cp oldnames/file_1 newnames/red
cp oldnames/file_2 newnames/yellow
cp oldnames/file_3 newnames/green
etc....

What I have tried (but doesn't work) -

#! /bin/bash
ls . |while read line
do
echo $line
cat names | while read xx
do
cp $line ../newnames/$xx
done

done

This creates new files but only copies the last entry from the ls to each of them Smilie

As you can see my scripting skills are not great - any ideas would be much appreciated.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Read .xlsx and text files in a loop using openpyxl

I have a list of .xlsx files (names 1.xlsx, 2.xlsx etc) in a directory, on which I need to insert data from its corresponding text file (named 1.txt, 2.txt etc) on the second worksheet named 'Filtered' and save it. The code I am trying is #!/usr/bin/python import os from... (8 Replies)
Discussion started by: nans
8 Replies

2. Shell Programming and Scripting

While loop a file containing list of file names until the files are found?

Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Discussion started by: laknar
5 Replies

3. Shell Programming and Scripting

Read loop from two files using descriptors

What I would like to do is read each line in the atdinfile: A sample atdinfile would look like this: 651 652 653 654 655 656 657 658 659 660 661 664 665 666 667 668 (5 Replies)
Discussion started by: woodson2
5 Replies

4. Shell Programming and Scripting

For loop inside awk to read and print contents of files

Hello, I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
Discussion started by: jaldo0805
5 Replies

5. UNIX Desktop Questions & Answers

Change name of files to their paths -- find loop

Dear All, I have many sub-folders but each of them have a file with same name but different data. I want to either move or copy them into a new folder but they need to have the path of where they are coming as part of their name... I have managed to find the files but dont know how to change... (2 Replies)
Discussion started by: A-V
2 Replies

6. Shell Programming and Scripting

Merging two columns from two files with similar names into a loop

I have two files like this: fileA.net A B C fileA.dat 1 2 3 and I want the output output_expected A 1 B 2 C 3 I know that the easier way is to do a paste fileA.net fileA.dat, but the problem is that I have 10,000 couple of files (fileB.net with fileB.dat; fileC.net with... (3 Replies)
Discussion started by: valente
3 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Writing a loop to changing the names of files in a directory

Hi, I would like to write a loop to change the names of files in a directory. The files are called data1.txt through data1000.txt. I'd like to change their names to a1.txt through a1000.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

Read and edit multiple files using a while loop

Hi all, I would like to simply read a file which lists a number of pathnames and files, then search and replace key strings using a few vi commands: :1,$s/search_str/replace_str/g<return> but I am not sure how to automate the <return> of these vis commands when I am putting this in a... (8 Replies)
Discussion started by: cyberfrog
8 Replies

9. Shell Programming and Scripting

Change files names

HI, Is there any possibility to change names of many files using "mv" and "for" loop ??? For ex. I have many txt files. file1.txt file2.txt ... And I tried something like this, but it's not working for (( i=1 ; $i<=10 ; i++ )) ; do mv file$i.txt newfile$1.txt; done (3 Replies)
Discussion started by: Physix
3 Replies

10. Shell Programming and Scripting

help writing script to read files names

Hi there, I am trying to do somehting similar, but on a wider scale. I am trying to write a script that would open the home directory, open the first (of 650) user's folder open the ?mail directory, which every user has Then I need the script to read each of the files and folder names with... (2 Replies)
Discussion started by: technett
2 Replies
Login or Register to Ask a Question
VRENAME(1p)						User Contributed Perl Documentation					       VRENAME(1p)

NAME
vrename - change signal names across many Verilog files SYNOPSIS
vrename <filename_or_directory>... DESCRIPTION
Vrename will allow a signal to be changed across all levels of the design hierarchy, or to create a cross reference of signal names. (It actually includes module names, macros, and other definitions, so those can be changed too.) Vpm uses a three step process. First, use vrename --list [<file.v>...] [<directory>....] This reads the specified files, or all files below the specified directory, and creates a signals.vrename file. Now, edit the signals.vrename file manually to specify the new signal names. Then, use vrename --change [<file.v>...] [<directory>....] ARGUMENTS
vrename takes the following arguments: --help Displays this message and program version and exits. --version Displays program version and exits. --change Take the signals file signals.vrename in the current directory and change the signals in the design as specified by the signals file. Either --list or --change must be specified. --changefile {file} Use the given filename instead of "signals.vrename". --changelang Include in the signals.vrename file the template needed to change the language standard for the file. For the first run, use "--list --changelang" and --language to specify the file's original language, then rerun with the "--change" option. The files will get escaped identifiers for the most recent Verilog standard. For example with --language 1364-2005, "do" will become "do ". --crypt With --list, randomize the signal renames. With --change, compress spaces and comments and apply those renames listed in the file (presumably created with vrename --list --crypt). The comment /*ENCRYPT_ME*/ must be included in all files that need to be encrypted, or use the --cryptall flag. If a signal should not be encrypted, it can simply be set in the signals.vrename list to be changed to itself. After encrypting, you may want to save the signals.vrename file so you have a key for decoding, and also so that it may be used for the next encryption run. When used in this way for the next encryption run, only new signals will get new encryptions, all other encryptions will be encrypted the same. --cryptall As with --crypt, but put cryptic names into signals.vrename even if the file does not include ENCRYPT_ME. Generally you will then need to edit the signals.vrename file manually to exclude any top level signals that should be preserved. --keywords Include keywords in the renaming list. Default is to ignore keywords, as changing a keyword will probably result in unrunnable code, however, occasionally it may be necessary to rename signals which happen to match the name of keywords recently added to the language (such as 'bit'). --language <1364-1995|1364-2001|1364-2005|1800-2005|1800-2009> Set the language standard for the files. This determines which tokens are signals versus keywords, such as the ever-common "do" (data- out signal, versus a do-while loop keyword). --list Create a list of signals in the design and write to signals.vrename. Either --list or --change must be specified. --nowrite Don't write the actual changes, just report the files that would be changed. --o {dir} Use the given directory for output instead of the current directory. --read Read the changes list, allows --list to append to the changes already read. --xref Include a cross reference of where the signals are used. --list must also be specified. DISTRIBUTION
Verilog-Perl is part of the <http://www.veripool.org/> free Verilog EDA software tool suite. The latest version is available from CPAN and from http://www.veripool.org/verilog-perl <http://www.veripool.org/verilog-perl>. Copyright 2000-2012 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0. AUTHORS
Wilson Snyder <wsnyder@wsnyder.org> SEE ALSO
Verilog-Perl, Verilog::Parser perl v5.14.2 2012-05-04 VRENAME(1p)