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

Bryan J Smith b.j.smith at ieee.org
Thu Oct 9 09:16:39 EDT 2008


Richard F. Ostrow Jr. Wrote:  
> cd /path/to/my/dune/mp3s
> for x in * ; do
> mv $x \[dune_3\]_$x
> done

Most definitely learn to use bash to its full extent, as you
can do a lot with it.  This really is one of those "I can write
this on a single line" type of problems.  The only thing I'd
recommend here is never use an open glob on its own, but
use characters with it to avoid changing files you did not
want to (or subdirectories for that matter).

E.g.,
$ for x in *.mp3 ; do mv $x \[dune_3\]_$x ; done

You can pass as many globs as you want betweeen the "in"
and ";" and the will expand to filenames that match.


--  
Bryan J Smith - mailto:b.j.smith at ieee.org  
http://thebs413.blogspot.com  
Sent via BlackBerry from T-Mobile  
    


-- 
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