Thursday, April 25, 2024
33
rated 0 times [  33] [ 0]  / answers: 1 / hits: 17435  / 2 Years ago, mon, august 29, 2022, 7:54:37

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"?


More From » command-line

 Answers
3

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...


[#33772] Tuesday, August 30, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ainlyyor

Total Points: 210
Total Questions: 129
Total Answers: 116

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
;