[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: renaming a file....

On 12/28/06, Cameron Simpson <cs zip com au> wrote:
On 28Dec2006 11:32, bruce <bedouglas earthlink net> wrote:
| i can use the find cmd, and generate the files i want to rename. however, my
| attempts at using the find . -name "foo" | xargs rename... doesn't seem to

You can try

 find . -name "foo" -exec mv -i {} newfoo \;

That will rename all the files named foo in the subdirectory structure
(after getting you to confirm the rename), but that won't show the
full path.  In addition, if you have files with the same name in
different subdirectories you may not want to rename all of them.
Another consideration is if you are looking at files with similar

What I like to do before any use of find to change a file is to know
what find "finds."

In the example above I will execute

 find . -name foo

and see what files are found.  The list returned will include the
relative path, so I will see something like:


Then I can do a couple of things.  I can gang rename:

 find . -name foo -exec mv {} foo2 \;

or, one at a time

 mv ./foo ./foo2
 mv ./subdir1/foo ./subdir/foo3


Tom Browder
Niceville, Florida

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]