convert spaces

Nils Kassube kassube at gmx.net
Wed Feb 20 08:09:52 UTC 2008


Michael Kadzioch wrote:
> How to convert spaces to underscores in linux filenames
> I am looking for an automatic (batched) solution.

find /path/to/some/directory -type f -name "* *"|while read f;do
  n=$(echo "$f"|tr " " "_")
  if test -e "$n"; then
    echo "$n exists."
    continue
  fi
  mv -v "$f" "$n"
done


Nils




More information about the ubuntu-users mailing list