[Leaplist] howto change the name of every file in a directory

Andrew aander07 at packetmaster.com
Thu Oct 9 10:59:49 EDT 2008


> cd /path/to/my/dune/mp3s
> echo *   # this shows the filenames that the shell will expand
> for x in * ; do
> echo mv $x \[dune_3\]_$x # adding the echo command will show what  
> would be normally be executed
> done


One small note that I have not seen anyone mention yet is that you  
probably want to quote the variable:

echo mv "$x" \[dune_3\]_"$x"

Otherwise, any files with a space in their name will cause mv to  
think it is getting more than just a source and a destination file  
name, and not know what to do with more than 2 arguements.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Leaplist mailing list