I would like to remove escaped characters from filenames, so these examples
=Web_Help_Desk_Pro%26Lite.pdf
=Windows_7_%2b_s-drev.pdf
would become
=Web_Help_Desk_ProLite.pdf
=Windows_7__s-drev.pdf
Does anyone know how to do this in either Perl or BASH?
If $file
is your filename:
my $file = '=Web_Help_Desk_Pro%26Lite.pdf';
$file =~ s/%[0-9a-f]{2}//gi;
i.e. replace %
followed by two hex characters with the empty string.
To just remove the percent sign and the following two hex digits:
$path =~ s/%[\da-f][\da-f]//gi;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With