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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-02-2009, 08:24 AM
|
#1
|
|
LQ Newbie
Registered: Jan 2008
Location: Eastern Australia
Distribution: Mint 6, 7, Ubuntu 9.04
Posts: 18
Rep:
|
Convert directory structure from long file names in Linux to DOS 8.3 structure?
Hi All,
I've been looking high and low for a utility program or perl script or something that can take a linux directory structure as input and convert it to MS-DOS 8.3 directory structure.
The purpose of this is to conform to the path format that is expected on my rather old Creative Zen Neeon MP3 player for m3u play lists.
Any ideas?
|
|
|
|
09-02-2009, 03:39 PM
|
#2
|
|
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Squeeze (Fluxbox WM)
Posts: 1,357
|
Some of this can be done with rename, though it is a bit crude (and doesn't handle name clashes or filenames without an extension):
Code:
find . -type d -exec bash -c 'cd "{}"; rename '\''tr/a-z/A-Z/;s/[ "*:<>?|]/_/g;s/(.{0,8}).*\.(.{0,3}).*/$1.$2/'\'' *' \;
Explanation - the 'find' searches for all the directories, the 'tr' transliterate changes to uppercase, the first 's' search changes illegal characters to underscore, and the second 's' search truncates the filename and extension.
Last edited by neonsignal; 09-02-2009 at 03:40 PM.
|
|
|
|
09-03-2009, 01:49 AM
|
#3
|
|
LQ Newbie
Registered: Jan 2008
Location: Eastern Australia
Distribution: Mint 6, 7, Ubuntu 9.04
Posts: 18
Original Poster
Rep:
|
Thanks neonsignal. That certainly helps. The harder problem is really sorting out the handling of long file names that do "clash" in 8.3 format as nearly all the files I will be dealing with have this problem, eg:
/home/Music/Bob Dylan - Hurricane.mp3
/home/Music/Bob Dylan - Isis.mp3
needs to become \HOME\MUSIC\BOBDYL~1.MP3 \HOME\MUSIC\BOBDYL~2.MP3 etc etc. So I really do have to worry about chars that aren't allowed in MS-DOS file names and getting the ~n thing right which means needing to know everything about the directory structure.
Another thought I've had is this: Is it possible to force Linux to read or list the shortnames on a VFAT mounted filesystem? It seems that when mounting a VFAT media device, Linux will always preferentially list the long file name entry rather than the shortname (8.3 format) entry. I might start this as a new thread ...
|
|
|
|
09-03-2009, 01:54 AM
|
#4
|
|
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Squeeze (Fluxbox WM)
Posts: 1,357
|
Have a look at the 'mcopy' command in the mtools package. I had assumed that your player didn't support DOS extended filenames.
Last edited by neonsignal; 09-03-2009 at 01:55 AM.
|
|
|
|
09-03-2009, 02:40 AM
|
#5
|
|
LQ Newbie
Registered: Jan 2008
Location: Eastern Australia
Distribution: Mint 6, 7, Ubuntu 9.04
Posts: 18
Original Poster
Rep:
|
Quote:
Originally Posted by neonsignal
Have a look at the 'mcopy' command in the mtools package. I had assumed that your player didn't support DOS extended filenames.
|
Thanks heaps! mtools was already installed on the system and all I had to do was edit the
file to make one of the drive letters point to the device associated with the mp3 player, in my case:
so my /etc/mtools.conf file now has this entry:
Code:
drive m: file="/dev/sde1"
when I come to use mdir, I have to use sudo:
Anyway, thatnks once again, neonsignal
|
|
|
|
09-12-2009, 09:18 AM
|
#6
|
|
LQ Newbie
Registered: Jan 2008
Location: Eastern Australia
Distribution: Mint 6, 7, Ubuntu 9.04
Posts: 18
Original Poster
Rep:
|
perl script to do the trick ...
Well, I got all excited about the mtools package and then discovered there was a bit more to it than that. Having a chance to revisit the problem, I decided to dabble in Perl and write my own script to do the job. It's pretty crude and not at all elegant, but if it might be of use to whoever needs some kind of starting point to do their own solution, I attach the code to this post.
Happy hacking!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:00 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
|
|