LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   convert all videos in folder script (http://www.linuxquestions.org/questions/linux-desktop-74/convert-all-videos-in-folder-script-4175454966/)

baloon68 03-21-2013 04:20 AM

convert all videos in folder script
 
I've some old video files in and I wanna convert them into mp3 ( I know there's youtube-dl option to do it at once - download&convert into mp3 straight but found it out just recently)
So here are 2 scripts I wrote ( the converting part ffmpeg is fine) but none of them working

1.First one)

#!/bin/bash
Files=/home/robert/Videos/nekonvert/* # the dir where videos are
cd /home/robert/Music/youtube/nezatried/konvert # the dir where the Vids'd be converted
for j in $Files
do
echo "processing $j file..."
#x=`cut -d\. -f1 $j` #option 1
x=$(cut -d\. -f1 $j) # option2
#cut the name of song e.g: songname.mp3 $x=songname
echo "name of song is :$x"

case "$x" in
mp4)
ffmpeg -i "$x.mp4" -aq 2 "$x.mp3"
echo "converting"
;; #konci moznost pre mp4
flv)
ffmpeg -i "$x.mp4" -aq 2 "$x.mp3"
echo "converting"
;;
*)
break #not flv or mp4 don't convert
;;
esac #case ends

# take action on each file. $j store current file name
cat $j #blank filename
done

2.Second one)

#!/bin/bash
cd /home/robert/Videos/nekonvert
ls > obsah.txt
file=obsah.txt
while IFS= read -r $file ## read recursive
do

x=$(cut -d\. -f1 $file)
#1st field before file=songname.mp4/flv x=songname
case "$x" in
mp4)
ffmpeg -i "$x.mp4" -aq 2 "$x.mp3"
;; #konci moznost pre mp4
flv)
ffmpeg -i "$x.mp4" -aq 2 "$x.mp3"
;;
*)
break; echo"nejaky divny file"
;;
esac #case ends

cat $file #blank filename for new file

done < "/home/robert/Videos/nekonvert/obsah.txt"
# process each by one by one in : obsah.txt


1)The first one starts echo : processing ... but then it writes some special characters and nuthin is converted
2) the second says: obsah.txt not a valid identifier??
Where am I wrong

GlennsPref 03-21-2013 06:48 AM

Hi, I'm using a GUI program winff to convert all sorts of files, sound and video.

Annother is ffmulticonverter.

Cheers, Glenn

baloon68 03-21-2013 09:44 AM

thanks for help
 
but I've found soundconverter meanwhile (pre installed with my mint13) maybe i'll try those you suggested, but I also want to learn how to script properly. nevertheless the initial problem is solved


All times are GMT -5. The time now is 10:07 AM.