LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-03-2003, 05:35 PM   #1
guygriffiths
Member
 
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524

Rep: Reputation: 37
A strange problem with 'mv'


I am trying to write a script to rename various files which I have. This needs commands such as "mv Music music", to try and lowercase my directory names. When I try this I get an error:

mv: cannot move `Music' to a subdirectory of itself, `music/Music'

I'd not come across this before, so I moved to another shell I had open, and tried again in /usr/src, where I had a directory named sisfb. I used the command "mv sisfb Sisfb". There was no problem, nor was there when I named it back. I then changed to the original directory and tried "mv Music music" but again it failed.

I have a feeling that this could be because the music directory is on a FAT32 partitioned harddrive. Has anyone come across this before, and does anyone know how to fix it?
 
Old 08-03-2003, 06:08 PM   #2
jqcaducifer
Member
 
Registered: Jul 2003
Distribution: Fedora 3
Posts: 133

Rep: Reputation: 15
Wow you really analyzed that problem good! Do instead:

rename Music music Music

Life will be easier

(the first and third arguments are the file to rename, and the second argument is the file name to rename to, the third option is used to rename more than one file, its confusing, "man rename")
 
Old 08-03-2003, 06:18 PM   #3
guygriffiths
Member
 
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524

Original Poster
Rep: Reputation: 37
Right, I tried that, only to get:
jam:/mnt# Bareword "music" not allowed while "strict subs" in use at (eval 1) line 1.

Plus, to be honest, I'm not actually using mv, I'm writing a perl script and using the rename function, but I found I could't get it to work, so I tried mv and got the problem I posted.
I also have got Perl to rename directories before, but no joy here.
 
Old 08-03-2003, 06:24 PM   #4
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
Having just tried the above rename command on a FAT32 directory, I have observed that it does not actually do anything.

The reason for this is because the FAT32 file system does not properly differentiate between upper and lower case names.

Create a directory, say x and try renaming it to all uppercase

mv x TMP

and you will see that the rename operation results in the x being renamed tmp not TMP.

So in order to rename Music to music, the way I have found to do it is as follows

mv Music X
mv X music

Obviously it is important that you do not already have a file or directory called X in the current directory.

If anybody can come up with a better working solution, then I would like
to hear it.
 
Old 08-03-2003, 06:25 PM   #5
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
So in your perl script use an intermediate directory name,
just like with mv example I just gave above.
 
Old 08-03-2003, 06:30 PM   #6
guygriffiths
Member
 
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524

Original Poster
Rep: Reputation: 37
I thought of that, but I didn't want to do it because it seemed so unelegant. However, if it is due to the FAT32 not differentiating cases then that's probably the only way.
Thanks, I'll do that.
 
Old 08-03-2003, 06:38 PM   #7
Corin
Member
 
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446

Rep: Reputation: 31
Hey remember, it is a VFAT32 file system, so it is a bit dumb (like Windoze).

From /usr/src/linux/Documentation/filesystems/vfat.txt

you can put the following options on your mount command for the VFAT32 partition

shortname=lower|win95|winnt|mixed
-- Shortname display/create setting.
lower: convert to lowercase for display,
emulate the Windows 95 rule for create.
win95: emulate the Windows 95 rule for display/create.
winnt: emulate the Windows NT rule for display/create.
mixed: emulate the Windows NT rule for display,
emulate the Windows 95 rule for create.
Default setting is `lower'.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strange, strange alsa problem: sound is grainy/pixellated? fenderman11111 Linux - Software 1 11-01-2004 05:16 PM
strange problem :) salmanucit Linux - Software 1 07-23-2004 06:47 PM
help with the 'mv' command please Lleb_KCir Linux - General 3 07-20-2004 11:21 PM
wx-config problem strange problem plz help glacier1985 Linux - Software 4 07-26-2003 05:20 PM
strange x problem frieza Linux - Software 0 03-25-2003 11:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:19 AM.

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