Replace invalid characters under NTFS

Discuss and share scripts and script files...
Post Reply
Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Replace invalid characters under NTFS

Post by Marco »

As we all know, there's a bunch of characters which aren't allowed in NTFS filenames in the Win32 namespace. I searched for a replacement for each of them ([1], [2]):

Code: Select all

\ → \
/ → ⁄,/
: → ꞉
* → ٭
? → ?
" → "
< → <
> → >
| → ǀ
Now, "sanitizing" any string before using it as a filename is as trivial as applying a replacelist(), namely

Code: Select all

 $string = replacelist($string, '\,/,:,*,?,",<,>,|', '\,/,꞉,٭,?,",<,>,ǀ');
But I wonder if any of you know of better, more graphically pleasing replacements. Here are a couple of screenshots with the two fonts used by Windows, Tahoma (XP) and Segoe UI (Vista and later).
To see the attached files, you need to log into the forum.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Replace invalid characters under NTFS

Post by admin »

Cute idea! (Although such filenames might trigger panic attacks in some users...)

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: Replace invalid characters under NTFS

Post by Marco »

Ahah, like curses in certain comic strips: ahr ahr grr @#+!!
Anyway, I can think of youtube videos and webpage titles: both of them can be saved, and both of them can contain such characters. Replacing them with the usual hyphen or underscore might be viable for asterisks and colons, but quotation and question marks often have an important meaning in sentences.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

admin
Site Admin
Posts: 66294
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Replace invalid characters under NTFS

Post by admin »

Marco wrote:Ahah, like curses in certain comic strips: ahr ahr grr @#+!!.
I rather thought: When I'd see a filename with a "?" on my machine I'd think it's defect. :)

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Replace invalid characters under NTFS

Post by TheQwerty »

I genuinely love the idea, but dislike the difficulty it brings to typing the names. :whistle:

I suppose with an AHK script to put your keyboard in NTFS-safe-mode it might not be so bad. ;)

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Replace invalid characters under NTFS

Post by binocular222 »

Here is the AHK꞉

Code: Select all

\::Sendinput {U+FF3C}
/::Sendinput {U+2044}
+;::Sendinput {U+A789}
+8::Sendinput {U+066D}
+/::Sendinput {U+FF1F}
+'::Sendinput {U+FF02}
+,::Sendinput {U+FF1C}
+.::Sendinput {U+FF1E}
+\::Sendinput {U+01C0}
All the Hex code is looked up from http://slayeroffice.com/tools/unicode_lookup/
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply