|
|||||||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
DriverHeaven Addict
Join Date: Sep 2002
Location: Elysium
Posts: 330
Rep Power: 0 ![]()
|
Can anyone help out with this simple command?
Hi,
Im trying to rename multiple files, using CentOS (fedora). I'm running the following command: find -iname .new-account | mv .new-account .new-user to change all files named .new-account to .new-user I keep getting "cannot stat .new-account: no such file or directory". But using just "find -iname .new-account" lists all the files I want changed. Im stuck! I also tried find -iname .new-account | rename 's/\.new-account/\.new-user/' but that doesnt work either (but it works in ubuntu), no error message given. Id appreciate any and all input you have! (and yeah, I AM a n00b at linux!) |
|
|
|
|
|
#2 | |
|
gargouille
Join Date: Jun 2002
Location: sector ZZ9 Plural Z Alpha
Posts: 962
Rep Power: 0 ![]() |
Re: Can anyone help out with this simple command?
Quote:
I don't use ubuntu; the rename command appears to be ubuntu-specific. I tried the line below on a Mac/bash, but should work mostly anywhere. This will find all files named .new-account starting from the current dir downwards; get the path using sed to remove the filename from the path (thus creating a list of paths that are stored successively in $i); cd there and rename the file; cd back and continue to the next file: Code:
for i in `find . -name .new-account | sed -e "s/\/\.new-account$//"`; do cd $i; mv .new-account .new-user; cd -; done Code:
\/\.new-account$ Code:
./path/to/.new-accounts/.new-account [edit] Here's a better way: http://snipplr.com/view/2736/rename-...r-expressions/ For your needs, the one-liner in the post above should be modified to: Code:
for i in `find . -name .new-account`; do j=`echo $i | sed 's/account$/user/'`; mv "$i" "$j"; done Code:
mv /path/to/old /path/to/new Also, 'rename' appears to be a perl script available on Debian: http://tips.webdesign10.com/files/rename.pl.txt
__________________
There is a war between the ones who say there is a war and the ones who say there isn't. ~~Leonard Cohen Last edited by merry; Nov 17, 2008 at 09:17 AM. |
|
|
|
|
|
|
#3 |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
Re: Can anyone help out with this simple command?
Seems like you are making it too complicated to me. Here is a snippet that works for me on FreeBSD:
Code:
find . -iname .new-account | sed 's/\.new-account$//' | xargs -n1 -I % mv %.new-account %.new-user
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 Last edited by Malus; Nov 27, 2008 at 12:32 PM. |
|
|
|
|
|
#4 |
|
Hopeless Dreamer
Join Date: Aug 2003
Location: Dreamland, near the pool of infinite graphics cards
Posts: 2,487
Rep Power: 57 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Can anyone help out with this simple command?
It was all much simpler on the Amiga...
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple question. | IFartOnYou | Hardware Discussion & Support | 12 | Jun 13, 2008 05:05 PM |
| Simple plugin for use with 'ma' console command | Russ | Effects and the DSP | 12 | Apr 14, 2008 02:53 PM |
| Do some simple tests for me? | Russ | Effects and the DSP | 37 | Apr 13, 2006 05:57 PM |
| Simple Question! | tonygg | General Discussion | 1 | Mar 3, 2005 06:58 PM |
| Help with a simple PC OC. | totally_tonedef | Overclocking and Modding | 27 | Oct 19, 2004 10:00 AM |