Convert directory structure from long file names in Linux to DOS 8.3 structure?
Linux - SoftwareThis 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.
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.
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.
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 04:40 PM.
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:
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 ...
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.