Bulk transcode using CLI not naming files correctly

HandBrake for Mac support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
ojobson
Posts: 2
Joined: Wed Jun 30, 2010 8:04 am

Bulk transcode using CLI not naming files correctly

Post by ojobson »

Hi,

I have written the script, below, which is run by automator whenever a new avi is dropped into a folder, but at the moment the output file is named "*.avi.mp4"

Any idea how to output the original file name, loose the original 'avi' extension and keep 'mp4'?

Thanks,

Code: Select all

DATEVAR=$(date)
for file in *.avi
do	
	echo "$DATEVAR start transcode of $file" >> /Volumes/Store/New\ Video/transcode-log.txt
	/Applications/Utilities/HandBrakeCLI -i /Users/Oliver/Desktop/test/$file -o /Users/Oliver/Desktop/test/$file.mp4 --preset="iPhone WiFi-lo"
	echo "$DATEVAR end transcode" >> /Volumes/Store/New\ Video/transcode-log.txt
done
jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Bulk transcode using CLI not naming files correctly

Post by jbrjake »

Code: Select all

--preset="iPhone WiFi-lo"
Umm....if you aren't modifying the source code I have no idea what you think that's going to do. Your script saves the encode logs, haven't you looked at them?

And to answer your question.... Read up on the sed command.
ojobson
Posts: 2
Joined: Wed Jun 30, 2010 8:04 am

Re: Bulk transcode using CLI not naming files correctly

Post by ojobson »

ah, not been using it long, thought it would work with custom profiles - it must have been running on default settings - ta.
The log file is simply to show that the script was running - doesn't provide any more information.

wow - sed. um complicated! I'll try and get my head round it...
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bulk transcode using CLI not naming files correctly

Post by JohnAStebbins »

Code: Select all

indir=${HOME}/Videos
for infile in ${indir}/*.avi
do
    outfile=$(echo ${infile} | sed -e "s/\(.*\.\)avi$/\1mkv/")
    echo ${outfile}
done
Post Reply