Art Alexion on 22 Feb 2006 14:40:21 -0000 |
I am trying to iron out a script that renames all files in a current directory to replace embedded spaces with underscores, and makes everything lower case. The suggestion that I was given was (in pertinent part): for OLD in * do NEW=`echo $OLD|sed s/\ /\_/g | tr [:upper:] [:lower:]` echo "OLD=\"$OLD\"" echo "NEW=\"$NEW\"" echo -e "mv \"$OLD\" \"$NEW\"\n" done But while the messages sent to the console indicated what I wanted to do was happening, and there were no errors reported, no changes were actually being made to the filenames. I read the echo man page and it seemed that the line echo -e "mv \"$OLD\" \"$NEW\"\n" didn't actually execute the mv command, so I added the line mv $OLD $NEW after it, so it now reads for OLD in * do NEW=`echo $OLD|sed s/\ /\_/g | tr [:upper:] [:lower:]` echo "OLD=\"$OLD\"" echo "NEW=\"$NEW\"" echo -e "mv \"$OLD\" \"$NEW\"\n" mv $OLD $NEW done But this results in the error mv: when moving multiple files, last argument must be a directory even though $NEW does not yet exist, so I am not really moving multiple files. What am I doing wrong? -- _______________________________________ Art Alexion Arthur S. Alexion LLC PGP fingerprint: 52A4 B10C AA73 096F A661 92D2 3B65 8EAC ACC5 BA7A The attachment -- signature.asc -- is my electronic signature; no need for alarm. Info @ http://mysite.verizon.net/art.alexion/encryption/signature.asc.what.html Key for signed PDFs available at http://mysite.verizon.net/art.alexion/encryption/ArthurSAlexion.p7c The validation string is TTJY-ZILJ-BJJG. ________________________________________ Attachment:
signature.asc ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|