(This is an excerpt from a PCWorld How To. For the full instructions, go to
http://www.pcworld.com/article/195367/a ... brary.html)
Start by grabbing the batch file template from the PCWorld page, then follow along. Note that batch files can do lots of things to your PC, and if you're not careful you might be converting a lot of videos.
Right-click on the convertvideotemplate.bat file and select Edit to open it up in Notepad. You should see this:
@for /r %%F in (*.[filetype], *.[filetype]) do (
"[location of handbrake CLI]" -i "%%F" -o "%%~pnF-ipod.mp4" --preset="iPhone & iPod Touch"
move /-y "%%F" "[location of processed videos dir]"
)
@for /r %%X in (*ipod.mp4) do (move /-y "%%X" "[location of Automatically Add To iTunes folder]")
start "" "[Location of iTunes app]"
pause
In order to adapt this to work for your PC, you're going to need to fill out each of bracketed areas with your own information:
-For [filetype], put the three-letter suffix of the kinds of files you want Handbrake to process. If I put (*.mp4, *.flv, *.3gp, *.avi), it means that it will look for all MPEG-4, Flash Layer Video, 3GP, and AVI files.
-For [Location of Handbrake CLI], you'll need the path to the Handbrake CLI app. It's typically in the same folder as the Handbrake GUI app, so just right-click on the Handbrake icon in your Start Menu and copy the location. You should end up with something like "C:\Program Files\Handbrake\HandBrakeCLI.exe".
-If you're converting your video to something other than an iPod Touch/iPhone format, you'll want to replace the "--preset="iPhone & iPod Touch" with a different set of encoding instructions. Here's a list of Handbrake's different preset encodes.
-We want to put the original files somewhere else once they're done being processed, or else this script will convert them again on the next run-around. I made a folder on my desktop called "Processed Videos" and pasted that into the [location of processed videos dir] section.
-iTunes 9 and later has an Automatically Add To iTunes folder which we're using to add our new movies to the iTunes Library. You can find it by going into your User folder, Music, iTunes, iTunes Media, Automatically Add To iTunes. Copy this file path into the [location of Automatically Add To iTunes folder].
-Finally, find the path to the iTunes application itself--typically "C:\Program Files\iTunes\iTunes.exe" and paste that in the [Location of iTunes app] spot. Assuming your iPod Touch is synced to your PC, iTunes should automatically sync on launch.
Once completed, your script should look something like this:
@for /r %%F in (*.mp4, *.flv, *.3gp, *.avi) do (
"C:\Program Files\HandBrake\HandBrakeCLI.exe" -i "%%F" -o "%%~pnF-ipod.mp4" --preset="iPhone & iPod Touch"
move /-y "%%F" "C:\Users\pmiller.PCWORLD\Desktop\Processed Videos"
)
@for /r %%X in (*ipod.mp4) do (move /-y "%%X" "C:\Users\pmiller.PCWORLD\Music\iTunes\iTunes Media\Automatically Add to iTunes")
start "" "C:\Program Files\iTunes\iTunes.exe"
pause
Now, we have a script that will grab all the videos of a certain type, pass them off to Handbrake, and add them to iTunes when they're done--try and run it with some sample files if you haven't already. Make sure to put it in the directory you want it to watch for videos before proceeding any further.
Next we just need to get it to run automatically. Enter Windows Task Scheduler, which you can find in Control Panel, Administrative Tools, Task Scheduler.
Start by clicking Create Basic Task on the right-hand side. Give it a quick name and description, click Next, and specify how often you want this task to run--we'll say Daily--and a time you want it to run (ideally a time when you're not using the computer, so you don't have to worry about the CPU getting bogged down by converting video).
Click Next again, leave it on Start a program, click Next, and paste the directory you want the batch file to watch over in the Start in (optional) field. (You may need to put the path in quotes if there are spaces in any of the folder names.)