RXP wrote:
Well I do, but with Sab's TV sorting option enabled it extracts it to a single folder. I guess I'll just manually add a category for ts files.
And it wasn't your fault, just glad I finally have a solution to joining ts files, been wanting one for like 2 years now!
I get SAB to put each episode in an episode sub directory. I then move them up one when I've done whatever I need to do to them. You could do that with
Ok - quick question then - this all works perfectly, but if I wanted to delete the entire directory, instead of just a single file, would this command work? : del "%dirname%" or do I need to do something different? I used your idea earlier around just writing the converted file directly to the proper converted directory, so now I just want to delete the entire directory that housed the source file (and other ancillary files)
I have one more question. The script has taken me on a new journey. Since I'm using it primarily for TV shows on Itunes (for the Iphone and Apple TV), I've decided that proper itunes tagging is also a requirement. To address that requirement, I've integrated "atomicparsley" into the mix which allows for proper tagging of the TV shows (by default Itunes files it as a movie)
set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
for /R "%dirname%" %%f in (*.avi) do HandBrakeCLI.exe -i "%%f" -o "C:\converted\%name%.m4v" -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 && AtomicParsley "c:\converted\%name%.m4v"
However I would love to be able to use attributes of the file or the folder to populate (a) the name of TV show (b) the season # and (c) the show # using atomicparsley - any ideas ?
set AtomicParsley="F:\Program Files\ipodvidconverter\Tools\AtomicParsley\AtomicParsley.exe"
set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
CALL :tagTVshow "mp4 filename.mp4"
GOTO :EOF
:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"
REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b
REM now tag the file with this information for iTunes
%AtomicParsley% %1 --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%
GOTO :EOF
set AtomicParsley="F:\Program Files\ipodvidconverter\Tools\AtomicParsley\AtomicParsley.exe"
set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
for /R "%dirname%" %%f in (*.avi) do HandBrakeCLI.exe -i "%%f" -o "C:\converted\%name%.m4v" -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 && CALL :tagTVshow "c:\converted\%name%.m4v"
GOTO :EOF
:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"
REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b
REM now tag the file with this information for iTunes
%AtomicParsley% %1 --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%
GOTO :EOF
obviously, I've just written this, so it's not had a large amount of testing yet! buyer beware
PS check out page 1 of this thread for a method to add the results to itunes for you too
Last edited by doubledrat on December 30th, 2008, 7:26 am, edited 1 time in total.
thanks - this is great- what expectations does the code have for the file name, file structure and deliminators? i.e. should I be setting sabnzbd to structure the TV show folder in any particular way?
Well - i think that's the newzbin set format. Which is great except I don't have a login there and therefore I just rely on other site to source my nzb via rss. However, with the folder sorting options in sabnzbd I believe I can adjust either the file name or folder name to be the same as what you have (except my nzb feed doesnt give me episode name either - which isn't a big deal to me)
so in summary, the only difference is that I would need to (a) parse the file (or folder) name rather than the nzb (b) not use episode name (instead just use show name, season number, and episode number)
I was hopin that something as simple as this would work
either you can force your filename, or using the directory name, you will need to split off %dirname% - you know the root of the directory, so you should be able to remove that with something like
Thanks for this atomicparsley application, the script worked wonders. I have with the help of wget.exe (google it) managed to get it to also grab tv show artwork
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"
REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
SET m4vfile="D:\Share\Disk1\-=-iPhone-=-\tvshows\%name%.m4v"
call :ToLowCase
:ToLowCase
setlocal enableextensions
set var_=%show%
set var_=%var_:A=a%
set var_=%var_:B=b%
set var_=%var_:C=c%
set var_=%var_:D=d%
set var_=%var_:E=e%
set var_=%var_:F=f%
set var_=%var_:G=g%
set var_=%var_:H=h%
set var_=%var_:I=i%
set var_=%var_:J=j%
set var_=%var_:K=k%
set var_=%var_:L=l%
set var_=%var_:M=m%
set var_=%var_:N=n%
set var_=%var_:O=o%
set var_=%var_:P=p%
set var_=%var_:Q=q%
set var_=%var_:R=r%
set var_=%var_:S=s%
set var_=%var_:T=t%
set var_=%var_:U=u%
set var_=%var_:V=v%
set var_=%var_:W=w%
set var_=%var_:X=x%
set var_=%var_:Y=y%
set var_=%var_:Z=z%
set var_=%var_:=†%
set var_=%var_:Ž=„%
set var_=%var_:™=”%
set var_=%var_:"=%
set var_=%var_:!=%
set var_=%var_: =_%
endlocal & set shownocaps=%var_%
REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b
REM now tag the file with this information for iTunes
Echo ## Episode = %value%
Echo ## Show = %show%
Echo ## Show No caps = %shownocaps%
Echo ## Season = %season%
Echo ## Episode = %episode%
Echo ## SeasonXEp = %seasXep%
Echo ## fileExt = %fileExt%
Echo ## Artwork = %artwork%
SET imagename=%shownocaps%-show.jpg
SET Artworkurl=http://sharetv.org/images/%shownocaps%-show.jpg
SET Imagepath=E:\temp\artwork\%shownocaps%-show.jpg
SET extravalue=--artwork %Imagepath%
IF EXIST "%imagepath%" GOTO Skipimagedownload
CD /d e:\temp\artwork\
e:\temp\artwork\wget.exe "%artworkurl%"
IF NOT EXIST "%imagepath%" SET extravalue=
Del need-%show%.jpg /q /f
IF EXIST soon.jpg ren soon.jpg need-%show%.jpg
:Skipimagedownload
Echo ##
Echo ## Now running Atomic Parsley
Echo ## Running d:\Atomic\AtomicParsley.exe %m4vfile% --overWrite --title "%value%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season% %extravalue%
d:\Atomic\AtomicParsley.exe %m4vfile% --overWrite --title "%value%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season% %extravalue%
set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
for /R "%dirname%" %%f in (*.avi) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
for /R "%dirname%" %%f in (*.mkv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
for /R "%dirname%" %%f in (*.wmv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "%dirname%\%name%.mp4"
Works like a charm
i put ffmpeg.exe inside C:\Windows\System32\ so i can use from anywhere in my system
thanks for posting this!
I'm using this script and it works AWESOME... with one exception- any movie split in to two files. On a completed download, sabnzbd goes through the whole par2/unrar process, moves it to the completed directory, then begins encoding part_1.avi as nzb_name.mp4, then when the first file is completed it starts encoding part_2.avi as nzb_name.mp4 again. Naturally this is overwriting the original file, so all I'm left with is an encoded part_2.avi.
Ideally, I'd like it to combine part_1.avi and part_2.avi THEN encode them to nzb_name.mp4... but I'd settle for it just not overwriting the first encoded file.
Any help would be greatly appreciated, this thread has been remarkable so far.
I just got an iphone finally, and this thread has been great. I am not very good with scripts, so its taken me hours of reading through this thread and I sort of understand it, but I am having a looping issue on the batch file I made. Could someone take a look at mine for me?
set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
for /R "%dirname%" %%f in (*.avi) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"
for /R "%dirname%" %%f in (*.mkv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"
for /R "%dirname%" %%f in (*.wmv) do ffmpeg.exe -y -i "%%f" -f mp4 -vcodec libx264 -level 30 -s 480x272 -r 30000/1001 -b 768k -bt 768k -bufsize 2000k -maxrate 768k -g 250 -coder 0 -acodec libfaac -ac 2 -ab 128k "g:\iphone tv\%name%.mp4" && CALL :tagTVshow "g:\iphone tv\%name%.mp4"
:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"
REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b
REM now tag the file with this information for iTunes
%AtomicParsley% "g:\iphone tv\%name%.mp4" --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%
REM don't repeat the exercise
IF EXIST "g:\iphone tv\%name%.mp4" GOTO :EOF
call cscript "c:\program files\sabnzbd\scripts\itunesupdate.js" "g:\iphone tv"
curl.exe --get "http://192.168.1.103/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)"
GOTO :EOF
I just added in: REM don't repeat the exercise
IF EXIST "g:\iphone tv\%name%.mp4" GOTO :EOF
But I obviously didn't do it right, b/c it is doing the same thing.
It loops at this part:
C:\Program Files\SABnzbd>curl.exe --get "http://192.168.1.103/xbmcCmds/xbmcHttp? ... ary(video)"
This version of C:\Program Files\SABnzbd\curl.exe is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
And starts ffmpeg again. It probably has something to do with the GOTO :EOF commands, but I'm not sure how to implement those.
Here is the output: http://pastebin.com/m4f69a59a
Thanks again.
Last edited by bnb on April 21st, 2009, 4:46 pm, edited 1 time in total.
@ECHO OFF
set AtomicParsley=%PROGRAMFILES%\AtomicParsley\AtomicParsley.exe
set targetDir=D:\iTunesMedia\TV Shows
set handbrake=%PROGRAMFILES%\HandBrake\HandBrakeCLI.exe
set name=%3
SET name=%name:" =%
SET name=%name: "=%
SET name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%
echo Directory: %name%
echo Name: %name%
set file=%targetDir%\%name%.m4v
echo Output File: %file%
rem for /R "%dirname%" %%f in (*.avi) do "%handbrake%" -i "\\%%f" -o "%file%" -e x264 -q 0.589999973773956 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -P -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1
for /R "%dirname%" %%f in (*.avi) do "%handbrake%" -i "\\%%f" -o "%file%" --preset="iPhone & iPod Touch" -v 0
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set year="%%b"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set month="%%c"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set day="%%d"
FOR /F "TOKENS=1-5 DELIMS=-" %%a in ("%name%") DO set guest="%%e"
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%
SET year=%year:" =%
SET year=%year: "=%
SET year=%year:"=%
SET month=%month:" =%
SET month=%month: "=%
SET month=%month:"=%
SET day=%day:" =%
SET day=%day: "=%
SET day=%day:"=%
SET guest=%guest:" =%
SET guest=%guest: "=%
SET guest=%guest:"=%
set title=%year%-%month%-%day%
echo Show: %show%
echo Title: %title%
"%AtomicParsley%" "%file%" --genre "TV Show" --stik "TV Show" --TVShowName "%show%" --title %title% --description "%guest%" --overWrite