[clug] renaming files to make windows happy

Nemo wombat at nemo.house.cx
Thu Apr 23 07:30:31 GMT 2009

Hi all

I have a large quantity of files with various win32 unfriendly
characters in the filename. (primarily ", ? and :, though those
obviously aren't the only ones that win32 can't handle. 

The files are going onto a NTFS partition (which as a fs can handle the
characters in filenames fine, and ntfs-3g puts them there for the sake
of "maximum portability and interoperability reasons" 
(http://www.ntfs-3g.org/support.html). (imho, this argument is bunk
since the main reason I think someone would want to write to ntfs is for
interoperability with a WindowsOS. 

Windows win32 layer can't handle all the characters. 

NTFS-3G doco suggests exporting the filesystem through samba for
compatibility. I don't particularly want to route all the files through
an additional network layer since they're already on the right machine. 


Does anyone have or know of a nice simple bulletproof script which will
take a filename, and make it safe to windows. (ie, convert win32
unfriendly characters to _ or ^ or similar? Handling filename escapes in shell
scripts sanely gives me willies ;)

thanks in advance!

More information about the linux mailing list