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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...