Re: renaming a file....

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

 



On 12/28/06, Cameron Simpson <cs@xxxxxxxxxx> wrote:
On 28Dec2006 11:32, bruce <bedouglas@xxxxxxxxxxxxx> 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
names.

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:

 ./subdir1/foo
 ./foo

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

Tom Browder
Niceville, Florida
USA

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux