Bash script help needed

trenton

Well-Known Member
Joined
Aug 20, 2007
Messages
263
Reaction score
194
Location
Harties
Hi all

I have a dir full of HE-AAC V2 files that I would like to put in .m4a containers with mp4creator, using this command;

mp4creator -create=*.aac *.m4a

where * is the file in the dir.

There are spaces in the file names.

That command needs to run for each file.

Any help please.
 
Briliant, thank you very much.

As soon as I can see straight I'll try that.
 
I would just do:
Code:
for FILE in *.acc
do
BFILE=${FILE%.*}
mp4creator -create="$FILE" "$BFILE.m4a"
done

Note that because the filenames have spaces it's important to surround $FILE and $BFILE with quotes - otherwise the name gets broken into multiple command line options.. ;)
 
Note that because the filenames have spaces it's important to surround $FILE and $BFILE with quotes - otherwise the name gets broken into multiple command line options.. ;)

Oh yeah. Quotes :p
 
I ripped about a gig of trance from DI-FM, and dreaded fixing each by hand.
I tried the first solution but errored out. My blood was up so I looked for a solution and found krename to fix the spaces.
After that the script work fine.
But will be using the second solution from now.

Thanks redarrow & Nod
 
I don't have much experiance with scripting, but you can also use sed.

eg. ls *.aac | sed -e 's/\ /\\\ /g'

That should output the directory listing with spaces escaped. Thou I don't know how to take the output from above and put it into "mp4creator -create=*.aac *.m4a" elegantly.
 
I don't have much experiance with scripting, but you can also use sed.

eg. ls *.aac | sed -e 's/\ /\\\ /g'

That should output the directory listing with spaces escaped. Thou I don't know how to take the output from above and put it into "mp4creator -create=*.aac *.m4a" elegantly.

You could use the resulting list as input for a loop (while read FILE;<something>;done < `your command`)
 
Top
Sign up to the MyBroadband newsletter
X