[Ilugc] [Tip] Renaming files

  • From: trshash84@xxxxxxxxx (T.R.Shashwath)
  • Date: Tue Apr 4 18:22:34 2006

On Tuesday 04 April 2006 17:36, Kumar Appaiah wrote:

Hello! I thought people might find this tip useful. Often, we find
that we have many files with spaces in the filenames (moreso when they
are got from a Windoze user). Now, I find it very difficult to use
those files keeping the spaces in the names intact. So, I use
something like the following one liner to convert all spaces to `_'
(underscore) in the file names

for i in *jpg; do mv "$i" "`echo "$i"|sed 's/ /_/g'`"; done

Similar solutions with better error checking can be written. You can
also code this in Perl, Python or even AWK. But, this works...

Hope you found this useful.

Kumar

Or, just use rename:
rename <from> <to> <files>

For example,
rename " " "" *.jpg

Shash
-- 
"Where shall  I  begin, please your Majesty ?" he asked.
"Begin at the beginning,", the King said, very gravely, 
"and go on till you come to the end: then stop."

Other related posts: