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

Re: bulk filename changes



Jason V Smith wrote ..
> I have a bunch of pictures that are named similar to this pb040016.jpg.in.out.

> What I want is to rename the file to this pb040016.jpg.

No perl, python, sed, nor awk required. Just depends on how big your "pile"
of pictures is.

For the current directory:

   for i in `find . -maxdepth 1 -name \*.jpg.in.out`
   do
     mv "$i" `basename "$i" .in.out`
   done

For the entire tree, remove the '-maxdepth 1' option.

For a specific directory, replace the '.' directory with the path to the starting directory.

This requires that you be using a recent GNU version of find, as is commonly found on recent vintage Linux systems. This is a Linux list, after all.

The 'find' command (in backticks, so it executes first) locates the files.
The 'for' loop iterates over the identified files.
The 'mv' command performs the rename.
The 'basename' command removes the ".in.out" portion of the filename, resulting in the corrected filename.

There are manual pages for the 'find' and 'basename' commands if you want to know more about how they work and other options you think might help.

Ta Da!

Mike/


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.