Trying to do a negative match, to replace all "strange" characters in file names on my USB stick. (The car's media player can't handle them. So I have to replace them with standard characters.)
Can't get the the regular expressions to do a negative match to work in the program.
In Perl I can use all of the following expressions with success:
- Code: Select all
$text =~ s|([a-zA-Z0-9 -_\n]*)[^a-zA-Z0-9 -_]+([a-zA-Z0-9 -_\n]*)|\1X\2|g;
$text =~ s|[^a-zA-Z0-9 -_\n]|X|g;
$text =~ s|[^\w\n]|X|g;
$text =~ s|[\W]|X|g;
All of them replaces characters outside of the range specified as expected:
- Code: Select all
#! /bin//perl
my $text = "01 - Blinkar Blå (singelversion).mp3
02 - Från min radio.mp3
03 - Mr Jones maskin.mp3
04 - Kroppens automatik.mp3
05 - Krafter vi aldrig känner.mp3
06 - Stockholmsserenad.mp3
07 - Vidare.mp3
08 - Bärande våg.mp3
09 - 5-e avenyn.mp3
10 - Blinkar blå (maxiversion).mp3";
$text =~ s|([a-zA-Z0-9 -_\n]*)[^a-zA-Z0-9 -_]+([a-zA-Z0-9 -_\n]*)|\1X\2|g;
print "$text \n";
$text =~ s|[^a-zA-Z0-9 -_\n]|X|g;
print "$text \n";
$text =~ s|[^\w\n]|X|g;
print "$text \n";
$text =~ s|[\W]|X|g;
print "$text \n";
Gives the expected output:
- Code: Select all
01 - Blinkar BlX (singelversion).mp3
02 - FrXn min radio.mp3
03 - Mr Jones maskin.mp3
04 - Kroppens automatik.mp3
05 - Krafter vi aldrig kXnner.mp3
06 - Stockholmsserenad.mp3
07 - Vidare.mp3
08 - BXrande vXg.mp3
09 - 5-e avenyn.mp3
10 - Blinkar blX (maxiversion).mp3
01 - Blinkar BlX (singelversion).mp3
02 - FrXn min radio.mp3
03 - Mr Jones maskin.mp3
04 - Kroppens automatik.mp3
05 - Krafter vi aldrig kXnner.mp3
06 - Stockholmsserenad.mp3
07 - Vidare.mp3
08 - BXrande vXg.mp3
09 - 5-e avenyn.mp3
10 - Blinkar blX (maxiversion).mp3
01XXXBlinkarXBlXXXsingelversionXXmp3
02XXXFrXnXminXradioXmp3
03XXXMrXJonesXmaskinXmp3
04XXXKroppensXautomatikXmp3
05XXXKrafterXviXaldrigXkXnnerXmp3
06XXXStockholmsserenadXmp3
07XXXVidareXmp3
08XXXBXrandeXvXgXmp3
09XXX5XeXavenynXmp3
10XXXBlinkarXblXXXmaxiversionXXmp3
01XXXBlinkarXBlXXXsingelversionXXmp3X02XXXFrXnXminXradioXmp3X03XXXMrXJonesXmaskinXmp3X04XXXKroppensXVidareXmp3X08XXXBXrandeXvXgXmp3X09XXX5XeXavenynXmp3X10XXXBlinkarXblXXXmaxiversionXXmp3X
(Last row converts the CR LF charaters too, hence the single line)
But I can't get any of those expressions to work inside Bulk Rename Utility.



...and so on...
Technically there's no need for the newline(\n) here, but it makes no difference. Have tried without that too.
Any ideas?