0

I want to extend a recent question which I have asked to remove french characters with a combination of find and rename:

Rename files and directories with French characters

Now I am facing some files and directories with a \ in their names which is not touched by the following command:

find . -depth -execdir rename -n '
 utf8::decode$_ or die "cannot decode $_\n";
 s{[^\w.\@+,#!?:&%~()\[\]/\\ -]}{?}gs;
 utf8::encode$_;
 ' {} +

I tried to use \\ to target that name but it seems to be the incorrect way. The file naming I am talking about looks like that:

$ls
'Links '

$ls -1b
Links\ *WHITESPACE*

Those dir names are causing PHP Code to break. For example when trying to move a file inside a dir with that naming.

How can I enhance the given command to also target the described names?

Mango D
  • 225
  • 2
  • 7
  • Possibly related: https://unix.stackexchange.com/questions/258679/why-is-ls-suddenly-wrapping-items-with-spaces-in-single-quotes – Jim L. Oct 24 '19 at 21:54
  • This may ultimately be another case of why not to parse the output of ls. If you can post the PHP code that is breaking, and sufficient context around it, someone may be able to guide you in how to make your PHP code more robust. – Jim L. Oct 24 '19 at 21:59

0 Answers0