Replace All Colons From Filenames With Terminal
I have a GB's worth of music on my HDD that was formatted with EXT4. I want to move these files to a FAT formatted HDD partition. However, I can't move most of my files because they have ":" in the names (For example, "Act 2: ....." for operas). Is there a way with command line to rename all of my files from "XXXX:XXXX" to "XXXX-XXXX"?
If all your files are in a single directory, try:
rename 's|:|-|g' *
(where * can be changed to something more restrictive if you'd like)
If you have many files in a directory tree, try this from the base of the tree:
find . -name "*:*" -exec rename 's|:|-|g' {} \;
You can add the option -n
right after rename
to have it tell you what it WOULD do without ACTUALLY doing it. This might help you avoid accidentally stepping on other files or something else bad...