Linux – Bulk rename or delete in Linux

bashbulk-actionlinuxrename

I have a bunch (about 10 gigs worth) of files that I need to copy from an external linux disk to a Windows machine. Unfortunately some file-names that contain the ":" character have got into this collection.

None of these colon files needs to be on the windows machine so I need a quick solution to zap or rename them.

What would you all recommend? (I'm assuming something like a bash / perl / python script in Linux. We don't have powershell on the Windows machine. )

Best Answer

Review the offending files.

find /path/to/files -name '*:*' -print

Delete the offending files.

find /path/to/files -name '*:*' -exec rm {} +

Rename the offending files with an underscore.

find /path/to/files -name '*:*' -exec rename ':' '_' {} +
Related Topic