Rename Files Downloaded Using youtube-dl
Gregg
If you have used youtube-dl to download content from YouTube then you know that the file names can get to be rather long. In addition to the video’s title there is a dash followed by what appears to be a random sequence of characters just before the file extension. If you find this to be annoying then here is a code snippet that you can use to remove it.
This will remove the last field separated by a ‘-’ and replace it with the file extension of your choice, .mp4 is used in this example:
#!/bin/bashfor i in *.mp4do# Remove everything from the last hyphen to the endfile="${i%-*}"# Rename the file and remove the space between 'file'# and the file extension on the flymv "${i}" "${file%%*( )}.mp4"done