I’m running openSUSE 13.2 64-bit and just ripped 100 cd’s with K3b to .mp3 but when I try to copy some of them to a USB drive or my NAS for back-up I get an error saying it can’t be copied. It appears that some of the folders and .mp3 files that were created by K3b have a “?” or a “:” in the name and when I rename the folder or file without these two symbols they transfer successfully. There are about 1,500 .mp3 files and probably half of them have these symbols in the name. I am using Dolphin and have tried to copy and paste as well as selecting all and “copy to” both drives with the same errors.
Is there a way to copy these files without going in and manually renaming hundreds of files?
Thank you in advance because any possible solution would save me a lot of time.
Just guessing that the USB and NAS are formatted using a filesystem which does not accept certain characters in a filename; eg. : delimits drivename and filename in Windows filesystems.
That happens, also, with NTFS file systems, and probably any other Windows file system.
I uploaded a shell script that I use, to susepaste.org
I left it at the default expire (one week or a bit less).
I call it “decolonize”, with the intended double meaning. Put it in your $HOME/bin and give it executable modes. If you call it without arguments, it gives a brief help line. Beyond that, you will have to read the script to work out how to use it.
I don’t think it uses anything that would not be in a normal install. Use at your own risk. (Written by me, so consider it to be in the public domain).
Thank you so much for posting this shell script! I have never used a shell script and my linux skills are the beginner level so I need a little more instruction if possible.
I copied and pasted the shell script into kate text editor and saved it as an .sh in the bin folder in my home directory and made it executable. All of my music is in the Music folder in their respective sub-folders for each album.
Can you help with where to go from here because I’m not sure what to do at this point with the shell script.
Go to the directory where the files are. And then use the command:
decolonize.sh *
### or
decolonize.sh -s _ *
The first version should rename all files contain “:” in the name, by deleting the “:”. The second form should instead replace “:” by “_”.
To act on a different character such as “?”, use
decolonize.sh -c"?" -s _ *
You probably need those quotes around the “?”, because that character has a special meaning to the shell.
The “*” at the end of the line (and do not quote that) matches all files in the current directory. So you should be able to rename all in one step unless the directory is very very big.
If you prefer, you can rename the command to just “decolonize” (without the “.sh”) making it slightly shorter to type the command name.
I wrote that script for my own mp3 collection (ripped with k3b). The only testing is with my own files.
-d (default) delete the colon (or other) character
-s x replace colon (or other) with substitute x.
-c y the character to replace (defaults to ‘:’)
USAGE=“decolonize -d -s x -c y ] file”
pretty much tells you all you need
So the stuff in ] are optional parameters that change how things work. file is the full path to the file or start in target directory. Note it appears that this only operates on one file at time so something like
ls *.mp3 | decolonize
This pipes ( | char means pipe) the output of the ls (list) command to the decolonize command. You can add the additional parameters if needed
That won’t work if there are spaces in the file names. And there probably are. Hmm, it won’t work anyway, because the file names are expected to be arguments, not stdin.
This is truly amazing nrickert and thanks for the additional clarification gogalthorp. I went into my Music directory and it worked like a charm for the 105 folders that I have. In order for me to make changes for each .mp3 file however I think I have to go into each album’s folder and run the script. I just tried it and it worked for all of the files in a single directory.
I don’t mind going into all 105 folders and running the script which shouldn’t take too long but as a learning experience I would like to know if I can run the script for all of the directories(albums) within the main Music directory so it corrects all of my .mp3 files?
Thank you again for this script, it’s my first time using one and it really shows me the power of linux.
On 2015-07-18 23:16, drhedberg wrote:
>
> Thanks John. It appears that Fat32 filesystems will not accept : or ?
> in the file name.
>
> Do you or does anyone know how to remove the : and ? from all of the
> files so I don’t have to rename each one manually?
Try “krename”.
Then, search options on the software used for mp3 creation to sanitize
file names for msdos/win compatibility, for the next time.