File renaming
File renaming
Is it possible to limit the allowed characters in a filename to just a-z, 0-9 and _ ?
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
Re: File renaming
Hmm, this RegEx
[^[a-zA-Z0-9_]]*
is supposed to find everything but a-z, A-Z, 0-9 and _
However, I've tried to use it with the Rename element for Search & Replace, but for some reason it doesn't seem to work :-/
[^[a-zA-Z0-9_]]*
is supposed to find everything but a-z, A-Z, 0-9 and _
However, I've tried to use it with the Rename element for Search & Replace, but for some reason it doesn't seem to work :-/
Re: File renaming
I did some tests and got it to work by using the following as search regular expression:
[^a-zA-Z0-9_]*
and setting Repeat to Consecutive
Can you try this?
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
[^a-zA-Z0-9_]*
and setting Repeat to Consecutive
Can you try this?
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
Re: File renaming
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.
It will replace å, ä and ö with Underscore, Space or remove the not allowed characters.
Re: File renaming
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
Re: File renaming
To be honest, I'm not really sure what the sentence about anchoring in Switch means.
I moved the ^ character in your regex based on this piece of info in the Switch documentation on regular expressions:
I moved the ^ character in your regex based on this piece of info in the Switch documentation on regular expressions:
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'.
Re: File renaming
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.
Re: File renaming
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.
Additionally, the caret (^) has the special meaning "not" only if it's the first character after an opening square bracket that starts a character set.
Putting everything together, "[^[a-zA-Z0-9_]]*" would be translated to "^[^[a-zA-Z0-9_]]*$", meaning: "start of the string, followed by 0 or more characters that are not [, a-z, A-Z, 0-9, _, or ], followed by the end of the string."
But, again, some of this depends on the regex engine being used so you may get different results in different products. Aren't regular expressions fun.
Re: File renaming
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.
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.