[arch-general] renaming files

Florian Pritz bluewind at xinu.at
Thu Mar 1 18:16:06 EST 2012


On 02.03.2012 00:13, pete wrote:
> Hi folks 
> 
> Bit sort of off topic but hopefully ok 
> 
> I have some 350 picture files  with names  along the lines of
> "IMG_7127 EOS-1D Mark III copy.jpg"    i would like to rename them all
> to more like "IMG_7127.jpg"  i have tried a few times tonight and cant
> get my head around it anyone got a script that can do it 
> 

If the string is always the same use this:

rename " EOS-1D Mark III copy" "" *.jpg

If not:

for file in *.jpg; do
  mv "$file" "$(echo "$file" | sed 's/regex here//')"
done

This won't be fast, but it gets the job done.

-- 
Florian Pritz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-general/attachments/20120302/5d60a545/attachment.asc>


More information about the arch-general mailing list