Find all illegal Windows characters in a folder and subfolder
I found a bash one-liner that finds each file and folder with invalid characters in the name and renames the file/folder, changing each invalid character to a dash:

find . -name "*[&lt;&gt;:\\|?*]*" -exec bash -c 'x="{}"; y=$(sed "s/[&lt;&gt;:\\|?*]\+/-/g" &lt;&lt;&lt; "$x") &amp;&amp; mv -n "$x" "$y" ' \;


It is possible that a file has an illegal name that would be corrected to the exact same legal name as another illegally named file (Example: two files named "fle"). The one-liner above will not change the name of the second (or further) illegally named file that would be corrected to the same name as the first. This means that you may still have some illegally named files after the one-liner runs. After you run this one-liner, run

find . -name "*[&lt;&gt;:\\|?*]*"


again to identify any illegally named files that still exist. One way to deal with this situation is to change the dash in the sed substitution to another character, e.g. underscore, and run the one-liner again.