Glam Prestige Journal

Bright entertainment trends with youth appeal.

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

download video

youtube-dl -o "/home/guillem/Desktop/youtube/Videos/$titol.$myext" $url

move 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 .bak
  • sed 's/\.bak$//' - remove .bak
  • xargs -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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy