Removing specific part of filename (what's after the second dash) for all files in a folder
Posted
by
Bodo
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Bodo
Published on 2014-06-11T14:16:06Z
Indexed on
2014/06/11
15:41 UTC
Read the original article
Hit count: 339
I use the command line utility youtube-dl
to download videos from YouTube and make mp3s from them with avconv
. I'm doing this under Ubuntu 14.04 and very happy with it.
The utility downloads the files and saves them with the following name scheme:
TITLE(artist-track)-ID.mp3
So an actual filename looks like:
EPIC RAP BATTLE of MANLINESS-_EzDRpkfaO4.mp3
Some other file names in the folder look like:
EPIC RAP BATTLE of MANLINESS-_EzDRpkfaO4.mp3
Martin Garrix - Animals (Official Video)-gCYcHz2k5x0.mp3
Stromae - Papaoutai-oiKj0Z_Xnjc.mp3
At first, this was no problem. It didn't bother me while listening to my music in Rhytmbox. But when moving to phone or other devices it is pretty confusing to see a so long name, and some players, like the Samsung ones, treat that last part (id after second dash) of the name as Album or something.
I'd like to create a bash script that removes what's after the second dash in the name for all files, so it'll make them like this:
From: Martin Garrix - Animals (Official Video)-gCYcHz2k5x0.mp3
To: Martin Garrix - Animals (Official Video).mp3
Is it also possible to instruct youtube-dl
to exclude the ID from now on?
I am currently downloading with the command:
youtube-dl --extract-audio --audio-quality 0 --audio-format mp3 URL
© Ask Ubuntu or respective owner