LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices



Reply
 
Search this Thread
Old 03-21-2013, 05:20 AM   #1
baloon68
LQ Newbie
 
Registered: Sep 2012
Location: Slovakia
Distribution: Mint 13, Ubuntu 12, opensuse 12.3
Posts: 11

Rep: Reputation: Disabled
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
 
Old 03-21-2013, 07:48 AM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

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

Annother is ffmulticonverter.

Cheers, Glenn

Last edited by GlennsPref; 03-21-2013 at 07:50 AM. Reason: spelling and links
 
Old 03-21-2013, 10:44 AM   #3
baloon68
LQ Newbie
 
Registered: Sep 2012
Location: Slovakia
Distribution: Mint 13, Ubuntu 12, opensuse 12.3
Posts: 11

Original Poster
Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Convert Videos in Linux with Arista LXer Syndicated Linux News 0 05-21-2011 08:01 PM
LXer: Convert YouTube Videos Into MP3s LXer Syndicated Linux News 0 10-20-2008 01:41 PM
Need software to convert videos from various formats everity Linux - Server 3 08-05-2007 05:37 PM


All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration