recursively changing chars in filenames
Soren Orel
soren.orel at gmail.com
Sat Jun 27 16:54:30 UTC 2009
Hi
I wrote a little script that removes spaces, dashes, and so on from the
filenames in a directory ($1), and lowercase all filename letters, etc.
how could I complete the script, that so it will "recursively" do the same
thing?
to start it: sh something.sh /home/user/somedir
cat something.sh
#!/bin/bash
cd $1
rename 's/_-_/-/g' *; rename 's/_/-/g' *; rename 's/ /-/g' *;
rename 's/á/a/g' *; rename 's/í/i/g' *; rename 's/ű/u/g' *; rename 's/ő/o/g'
*; rename 's/ü/u/g' *; rename 's/ö/o/g' *; rename 's/ú/u/g' *; rename
's/ó/o/g' *; rename 's/é/e/g' *;
rename 's/Á/a/g' *; rename 's/Í/i/g' *; rename 's/Ű/u/g' *; rename 's/Ő/o/g'
*; rename 's/Ü/u/g' *; rename 's/Ö/o/g' *; rename 's/Ú/u/g' *; rename
's/Ó/o/g' *; rename 's/É/e/g' *;
for i in *; do mv "$i" "`echo "$i" | tr [A-Z] [a-z]`"; done
rename 's/&/and/g' *; rename 's/\*/-/g' *; rename 's/\\/-/g' *; rename
's/\$/-/g' *; rename 's/\?//g' *;
rename 's/--/-/g' *; rename 's/---/-/g' *;
thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20090627/1a1897fb/attachment.html>
More information about the ubuntu-users
mailing list