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

Re: renaming files



"oj ." <pegoj@hotmail.com> writes:

> I have a bunch of files (*.mp3) that have spaces and characteres
> such as: ", ( ,_. I would like to remove all the spaces and
> characteres and leave them as: xshkjds_jskdjks_jsdj.mp3.

for name in *.mp3; do
  newname=$(echo "$name" | sed -e 's/[ "\(\),]//g')
  echo "Moving \"$name\" to \"$newname\""
  mv -i "$name" "$newname"
done

You should first test the code without the mv-command and check the
output. The sed-command removes the chars: ` ', `"', `(', `)',
`,'. You may have to edit the regular expression in the sed-command,
if it's not exactly, what you want...

        hth,
	moritz
-- 
Moritz Schulte <moritz@chaosdorf.de> http://www.chaosdorf.de/moritz/
Debian/GNU supporter - http://www.debian.org/ http://www.gnu.org/
GPG fingerprint = 3A14 3923 15BE FD57 FC06  B501 0841 2D7B 6F98 4199



Reply to: