Death of Win32 files and the rise of POSIX files among file traders

This week’s tip is on fixing filenames on files created under Windows for use on all computing systems(pda/smart phones, Unix, Linux, OS X, and Windows).

To begin with, the history of filenames originates with DOS and other operating systems like it and how limited storage devices once where. Names only could be in a max of  8.3 characters format, which was 3 bytes and a fourth byte for the location on the drive or disk. then along came Windows 4 which followed to some extent the standard of the time named POSIX. Other OS notably using this standards was all UNIX systems, OS/2 and even apple’s System 7 better known as MacOS. Now, for those you that remember the time, Bill Gates was working along side Apple and IBM but we knew better. Anyways, what happen though of the time was that a whole influx was introduced by the use of expanding the filenames and now using the whole set of characters. You see this was possible because of the POSIX standards, plus OS/2 and MacOS practice of using metadata to extend the GUI past the prior limitations. Microsoft wasn’t so wise they decided that metadata files wasn’t the way to go and put the new extended filenames directly into the filename itself lead to awkward file that didn’t mesh well on other systems. You Still see this practice today, OS X while has Darwin a BSD descendant and thus POSIX compatibility, plus Nautilus and konquer on Linux all follow the practice of putting the awkward characters into the filename and breaking the POSIX standards.

So, what to do about it while not going to extremes and still being able to work in the same way? Well since we don’t want to change a working system, albeit a flawed one. We just use our know how in shell scripting, with the following one liner script:

#!/bin/shfor file in *\ *; do mv $file $(echo $file|sed "s/\ /_/g"|sed "s/'//g"); done

What this does is enumerate each file with a space in its name, then passes that through the stream editor to substitute each space character for ‘_’. How it does this is by looping through the files and before moving the file, fixes the name then moves it to the new name.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s