HOWTO: rename all files in lowercase
Pretty simple.
- If you don’t have a *NIX operating system, please skip this post.
- Create a script with this content:
#!/bin/sh for f in *; do g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'` mv -n "$f" "$g" done
and call it “rename.sh”
- Give it execution permissions, typing:
chmod u+x rename.sh
- Execute the script from the directory where you have your files to rename
If you have two files, “Foo” and “foo“, you’ll be notified and no files will be overwritten. So, don’t worry about that, you won’t lose any information. To be sure, try it with a few files in “/tmp” directory.
Question? Suggestion? Comment!



Luca De Vitis 6:26 pm on July 29, 2011 Permalink |
ls -1 | while read file ; do mv -nv “${file}” “$(echo “${file}” | tr ‘[A-Z]‘ ‘[a-z]‘)” ; done
diegor 6:53 pm on July 30, 2011 Permalink |
Hi Luca, thanks for the trick.
I tried but it doen’t work.. I have this:
“namefile not overwritten”
It works only if I drop “-n” option from mv command (too risky!!)