I have some files and folders that were saved in Linux on an external HDD, some of these files and folders contain the characters "::" I want to remove these characters from all files and folders on the drive as I get problems when trying to view the files in windows.
I have successfully removed them from one folder by using in terminal-
rename 's/:://' *::*.*
when in that single directory but want to do it for all files and folders on the drive, and there are many sub folders.
What can I add to the above command to make it work on all sub folders and files in the sub folders or is there a better command.
Thank you.
Best Answer
You can use the
find
command to search for files and directories recursively ex.The
-depth
is important if you are renaming files and directories (otherwise the command may "orphan" some matched files by renaming their containing directories before it has a chance to rename them). If you only wish to rename files, then you can add-type f
and drop the-depth
.I recommend running the command first with
rename -n
to make sure that it is doing the right thing.