How to quickly rename files on NAS I have recently added a Qnap (Linux) NAS to my Mac OS environment, as the main file server.
I realized many of the Mac OS files have / characters, that do not behave well in Linux, as they disappear when seen from Macs (they actually are being renamed in Linux and becoming invisible from the Macs... dunno why).
Example: a file named image/b.jpg should be renamed as image_b.jpg to avoid problems on the Qnap Linux NAS.
Anyway, I'd like to build a script from Mac OS Terminal to access the Linux NAS and perform a &quot;search and change&quot; of the / character to something else like: _.
I have begun by writing this:
ssh admin@192.168.2.2
for f in $(find /share/Public/ -name &quot;*:*&quot;); do mv $f ${f/:/_}; done

I can log on the remote NAS, but seems not to work... I am not a tech guy, and tried to collect some code samples from the internet.
What are options to automate or script file renames for a NAS share?
Running for over the results of a find is not recommended, it will break on filenames with spaces, newlines etc.
You can use the following instead once you are logged into your NAS:
find /share/Public/ -depth -name '*:*' -exec sh -c 'mv -- &quot;$1&quot; &quot;${1//:/_}&quot;' _ {} \;

To be on the save side, run
find /share/Public/ -depth -name '*:*' -exec sh -c 'echo mv -- &quot;$1&quot; &quot;${1//:/_}&quot;' _ {} \;

and check the output for anything unexpected.
PS: The duplicated // in ${1//:/_} is intentional to ensure that all occurrences of : are replaced.