Jump to content

Changing case of file name.


aperahama
 Share

Recommended Posts

Hi

 

Can anybody tell me if there is an easy/quick way of converting file names from from upper to lower case letters and vice-versa. I have some programmes that run on both Windoes and Linux but the data files have not been set up correctly to deal with case sensitive file names. Its a bit of a fag having to retype each one individaully.

 

Thanks for any help you may be able to give.

(I'm running Mandrake 9.2, if that makes any difference)

Link to comment
Share on other sites

Try opening a console and type

 

man rename

 

to explore the rename command. Read carefully and backup your work first so you can experiment..

Rename does the trick, but here are a couple of other ways to do it in a more *purist* point of view:

 

Converting files from upper case to lower case in a *single* directory:

 

~$ for file in *; do mv "${file}" "$(echo $file | tr 'A-Z' 'a-z')"; done

 

Recursively:

 

~$ find ./ -type f -exec bash -c 'f=$(basename "$1"); d=$(dirname "$1");  mv -i "$d/$f" "$d/$(echo $f|tr "A-Z" "a-z")"' {} {} \;

Edited by aru
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...