1

How can I turn:

/media/MediaOne/Movies/Kids/Aladdin.avi
/media/MediaOne/Movies/Kids/Incredibles.avi

into

/media/MediaOne/converted/Aladdin.mp4
/media/MediaOne/converted/Incredibles.mp4

when looping a directory using avconv?

Right now, they are outputted as:

/media/MediaOne/Movies/Kids/Aladdin.avi.mp4
/media/MediaOne/Movies/Kids/Incredibles.avi.mp4

and here is what I am trying:

for i in /media/MediaOne/Movies/Kids/*.avi; do avconv -i "$i" -c copy "$i.mp4"; done

tried this too:

for i in /media/MediaOne/Movies/Kids/*.avi; do avconv -i "$i" -c copy "/media/MediaOne/converted/$i.mp4"; done

but got a bunch of errors, because $i/media/MediaOne/converted/ did not exist

1
  • tried i%, but the files were named i%.mp4 – Kevin Jan 26 '14 at 18:55
2

Use basename command to remove extension from file name, notice special quotation marks

`$(basename $i .avi).mp4`

instead of

"$i.mp4"

dirname may help to extract path to folder containing input file. (man dirname for help)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.