Hi all,
I’ve been breaking my head on this for the past while and I figured I’d ask the hive mind here.
I’m using Double Commander as my file browser of choice, and I’m copying some files to an SD card that goes into an mp3 player running Rockbox, which only accepts FAT32 file systems.
I’ve tried to get all the filenames as compatible with FAT32 as possible, but here and there there’s still some file names that contain symbols incompatible with FAT32 ( , \ , / , : , * , ? , " , < , > , | .)
Now, Double Commander allows to use file templates for copying files, which includes the option for a file mask using regex. I figured I ought to be able to use this to skip files using these characters. Looking at regex syntax and googling for something similar to have already been done (I found this Stackexchange question) I came up with this regular expression:
[^\\/:*?\"<>|]
Double commander then spits out the following error, though:
Unhandled exception: ERegExpr: TRegExpr compile: quantifier ?+*{ follows nothing (pos 1)
Any ideas on what I’m doing wrong? Regex is kind of foreign to me, so I’m guessing I’m doing something fundamentally wrong that should be easy to solve for someone who knows what they’re doing.
I’m not familiar with the TRegExpr engine and its quirks, so I could be wrong about some or all of this, but let’s try anyway:
The characters in the brackets describe a set of characters, but without any quantifier after the brackets, they will only match a single character. If you want to match an entire string, you should begin the regex with a ^ character (which means “start of string” when outside brackets), have a quantifier such as * or + after the list and then end it with $ (“end of string”).
The ^ character reverses the list, so it will match any characters not in the list. This may be what you want (i.e. to copy all the files that matches because they do not contain the characters in the list), but I feel that it should be mentioned.
I suspect that you may need to escape the / character with a . And since the error message mentions * and ? I’d also try escaping those.
So to match only the filenames that are FAT32 safe, I’d try something like this:
^[^\\\/:\*\?\"<>|]+$
https://regex101.com/ is a great site for learning regex so I’d recommend that you try it out there (and keep in mind that different regex engines can have subtle differences, but sadly the site doesn’t do TRegExpr).