LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-06-2010, 03:13 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
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.
 
Old 01-06-2010, 03:31 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
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
 
Old 01-06-2010, 03:56 PM   #3
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
Quote:
Originally Posted by John VV View Post
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
$
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i restore lower case filenames in a source code package? unclejed613 Linux - Software 6 01-02-2010 09:33 AM
How do I manually mount a FAT32 external drive in Kubuntu 7.0.0? higleyg Linux - Newbie 1 05-26-2008 05:37 PM
script to list the filenames which are in lower case naveensankineni Programming 2 03-12-2008 07:09 AM
Do I need to defragment an external USB fat32 drive? pwc101 Linux - Software 3 08-22-2007 06:11 PM
Problem resizing FAT32 partition on external drive dyw Linux - General 10 04-16-2007 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration