LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   A strange problem with 'mv' (https://www.linuxquestions.org/questions/linux-software-2/a-strange-problem-with-mv-78676/)

guygriffiths 08-03-2003 05:35 PM

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?

jqcaducifer 08-03-2003 06:08 PM

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")

guygriffiths 08-03-2003 06:18 PM

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.

Corin 08-03-2003 06:24 PM

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.

Corin 08-03-2003 06:25 PM

So in your perl script use an intermediate directory name,
just like with mv example I just gave above.

guygriffiths 08-03-2003 06:30 PM

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.

Corin 08-03-2003 06:38 PM

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'.


All times are GMT -5. The time now is 11:46 PM.