i transferring lot of mac data user windows machine , trying remove illegal windows characters. have used following post, doesn't handle spaces or ( on mac data.
find . -name "*[<>:\\|?*]*" -exec bash -c 'x="{}"; y=$(sed "s/[<>:\\|?*]\+/- /g" <<< "$x") && mv "$x" "$y" ' \; so syntax error near unexpected token `(' brackets
and no such file or directory spaces in.
the suggested answer @meuh not work osx because relies upon non-posix regular expression. written gnu sed, diverges in many respects standard.
bres (used sed) not accept + in expression. instead, 1 uses range followed zero-or-more copies (*) of range.
here working script:
#!/bin/sh find . -name "*[<>:\\|?*]*" 2>/dev/null | sed "p; s/[<>:\\|?*][<>:\\|?*]*/- /g" | while read x; read y if test "x$x" != "x$y" mv -v "$x" "$y" fi done and output (starting file named ".baf fled/f<>foo2."):
./baf fled/f<>oo2. -> ./baf fled/f- oo2.
Comments
Post a Comment