Re: Bash Help: Renaming all files in a Directory

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patrick Doyle wrote:
>>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

The spaces in the file names will make this fail.  The loop will split
the files at the spaces, so you'd end up with f=Family, then f=Pic,
etc.  You can muck around with the IFS variable, but to me it always
seems easier to just use a while loop instead. :)

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
If you can stay calm, while all around you is chaos ... then you
probably haven't completely understood the situation.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkTBavwmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1ocYgCg3HNa4Jy8HvN77D3t8Xm7VssAdLoAoIbGz7qy
MStbWwmTPLpNz5n4YicR
=vt2W
-----END PGP SIGNATURE-----


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

  Powered by Linux