File renaming
Posted: Thu Oct 25, 2018 11:07 am
Is it possible to limit the allowed characters in a filename to just a-z, 0-9 and _ ?
That's good to know, Padawan. I'm not an expert in RegEx, but I guess it has to do with the message in Switch saying tha the RegEx is automatically anchored at both ends?Padawan wrote: ↑Thu Oct 25, 2018 5:36 pm
Terkelsen, your regex worked in online regex testers for me, that made me believe it was something specific to the engine used in Switch. Then I checked the regular expression part of the Switch documentation and that's how I found what was wrong
http://www.enfocus.com/manuals/UserGuid ... ions.html
And I suggested to set Consecutive as repeat mode because in my testfile I had bad characters at the front and at the back of the filename and that was the only way I could clean it up correctly.The caret negates the character set if it occurs as the first character, that is immediately after the opening square bracket. For example, [abc] matches 'a' or 'b' or 'c', but [^abc] matches anything except 'a' or 'b' or 'c'.
Jan Suhr, this will definitely remove or replace the characters like æ,ø,å,ö,ä, but it will still allow special characters like &,%,# etc.jan_suhr wrote: ↑Thu Oct 25, 2018 6:44 pm In the "Rename Job" element you have the option "Reduce character set" in it you can set the "Allowed character set" to "Portable ASCII" and that will give what you want.
It will replace å, ä and ö with Underscore, Space or remove the not allowed characters.
I would guess it means that an expression "x" is equivalent to "^x$". That is, Switch automatically adds the start of string (^) and end of string ($) anchors.
The square brackets denote a character set. What happens when you have another square bracket inside that set depends on the engine that's used. Most often, it's seen as a literal character. So for example "[[]]" means "the character set with characters '[' and ']'. There are a few exceptions, like the sequence "[:" which starts a special ("POSIX") character class.
Correct, that's why I need to limit the characters allowed in the file names even more. especially since I sometimes use "-" as a delimiter and quite a few customers use that character in their file names as well, which cause problems. Hence I'd like to limit the characters to basically letters and numbers.Terkelsen wrote: ↑Fri Oct 26, 2018 1:26 pmJan Suhr, this will definitely remove or replace the characters like æ,ø,å,ö,ä, but it will still allow special characters like &,%,# etc.jan_suhr wrote: ↑Thu Oct 25, 2018 6:44 pm In the "Rename Job" element you have the option "Reduce character set" in it you can set the "Allowed character set" to "Portable ASCII" and that will give what you want.
It will replace å, ä and ö with Underscore, Space or remove the not allowed characters.