LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Lower-casing filenames on fat32 external drive (https://www.linuxquestions.org/questions/linux-general-1/lower-casing-filenames-on-fat32-external-drive-780361/)

devnull10 01-06-2010 03:13 PM

Lower-casing filenames on fat32 external drive
 
Hi,
I have an external harddrive which is fat32 (which was filled when I was on a windows system) with a lot of files on (> 200gb) which have mixed case filenames. I wanted to write a script to rename them all to lowercase however when I did I got an error saying that the filenames are the same (which I guess is true as FAT is case-insensitive). My issue is that I'm mounting this from a linux box now so it would make it a lot easier if things were lower case! I've already run a script to replace all spaces with underscores.

I know I could do this by first going through and renaming everything with a prefix and then renaming it back again (ie, rename File.Jpg to xFile.Jpg and then a second rename to strip that x off and rename lowercase to file.jpg) however I find this approach a bit messy and would prefer to do it all in one pass.

Other than that, could I change the drive to ext4 without losing any files on it? The drive has a hell of a lot of stuff on there which is an archive of many years of files - I'd be absolutely gutted if I lost everything.

John VV 01-06-2010 03:31 PM

this will change names from cap to lower
It might need some editing to fully comply with your needs -- but might not.( it will rename the whole name )
Code:

#!/bin/sh

for i in *; do mv "$i" "$(echo $i | tr '[A-Z]' '[a-z]')"; done


devnull10 01-06-2010 03:56 PM

Quote:

Originally Posted by John VV (Post 3816714)
this will change names from cap to lower
It might need some editing to fully comply with your needs -- but might not.( it will rename the whole name )
Code:

#!/bin/sh

for i in *; do mv "$i" "$(echo $i | tr '[A-Z]' '[a-z]')"; done


Hi,
That is pretty much exactly the same as the script I wrote however my issue is that because the filesystem is fat32, upper and lower filenames are considered to be the same.
eg:

Code:

$ touch FileName.Ext
$ mv FileName.Ext filename.ext
mv: `FileName.Ext' and `filename.ext' are the same file
$ ls
FileName.Ext
$



All times are GMT -5. The time now is 01:58 AM.