How can I remove the default extension of my download video with a script.
Thanks for your help.
Here's the code I have so far:
read -p "enter URL:" url
read -p "enter title:" title
read -p "enter extension:" myext
youtube-dl $url --restrict-filenamesdownload video
youtube-dl -o "/home/guillem/Desktop/youtube/Videos/$titol.$myext" $urlmove video to my folder with 2 extension (title.myext.defaultext)
2 Answers
Searching Ubuntu's packages would find the rename utility, it's man page has this as it's first example:
For example, to rename all files matching "*.bak" to strip the extension, you might say
rename 's/\.bak$//' *.bak
Rename sounds like the ideal utility, but if you need more flexibility, you can use a oneliner to do it:
For example, to get rid of the extension and move it to $DIR (run from the dir where the files are)
ls *.bak | sed 's/\.bak$//' | xargs -I % mv %.bak $DIR/%
ls *.bak- find all files ending in.baksed 's/\.bak$//'- remove.bakxargs -I %- run the next command per input, putting the input wherever there is a%mv %.bak $DIR/%- move the original file (by readding the extension) to $DIR without the extension