Re: Bash Help: Renaming all files in a Directory

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

 



On 7/21/06, Thom Paine <painethom@xxxxxxxxx> wrote:
I'm making a digital picture frame out of an old laptop and the pic
viewer doesn't support filenames with spaces in them.

Is there a quick command I can type to process all files in a
directory that will rename the files from "Family Pic 001.jpg" to
"FamilyPic001.jpg"?

Off the top of my head...
$ for f in *.jpg; do; mv $f `echo $f | sed 's/ //g'`; done

(Be careful about the back (single) quotes and the forward single quotes.

BTW, when I write little shell ditties like this, I usually starft with:

$ for f in *.jpg; do; echo mv $f `echo $f | sed 's/ //g'`; done

(Notice the "echo" command conveniently placed to avoid actually doing
anything.)

Also, I usually try the command on a _copy_ of my original directory
(cp -a old_dir new_dir) first, just in case...

hth

--wpd


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux