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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-03-2003, 05:35 PM
|
#1
|
Member
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524
Rep:
|
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?
|
|
|
08-03-2003, 06:08 PM
|
#2
|
Member
Registered: Jul 2003
Distribution: Fedora 3
Posts: 133
Rep:
|
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")
|
|
|
08-03-2003, 06:18 PM
|
#3
|
Member
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524
Original Poster
Rep:
|
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.
|
|
|
08-03-2003, 06:24 PM
|
#4
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
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.
|
|
|
08-03-2003, 06:25 PM
|
#5
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
So in your perl script use an intermediate directory name,
just like with mv example I just gave above.
|
|
|
08-03-2003, 06:30 PM
|
#6
|
Member
Registered: Jun 2003
Location: Reading, UK
Distribution: Debian 3.0, LFS
Posts: 524
Original Poster
Rep:
|
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.
|
|
|
08-03-2003, 06:38 PM
|
#7
|
Member
Registered: Jul 2003
Location: Jette, Brussels Hoofstedelijk Gewest
Distribution: Debian sid, RedHat 9, Suse 8.2
Posts: 446
Rep:
|
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 02:36 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|