It seems that there are a lot of people that have been struggling with their TiVo. Like me they want to watch shows when the want, where they want and on the device they want. The problem is getting the recorded show off the TiVo, decrypted, edited then transcoded into a file type that their personal device can play.
I originally wrote about an application called iTiVo that made this process a lot easier.
TiVo & the Mac - Downloading TiVo files
Then an OS update broke iTiVo so I wrote up a work around. You can read about it here:
TiVo to Mac - Mountain Lion Edition
After a few months, when iTiVo finally became usable again, I wrote up a quick way to update the beta version to get full functionality back.
Continuing Adventures with iTiVo
I don't know when iTiVo will be updated to work without major surgery but hopefully it will be soon. So while we wait I want to answer a question that has been asked a lot during this whole process; How do I create a Apple Workflow that will process multiple files? This question doesn't just apply to processing TiVo files of course but I'll use that as my example.
Apple provides a great tool for speeding up and automating your work tasks. It's called Automator. It's an easy tool to get to know but getting it to do just what you want, in the way you want can be a trial.
Let's assume for a minute that iTiVo is broken again and you want to watch the entire season of Supernatural that currently sits on your TiVo. Downloading the files is easy. You can use the web version I wrote up here, or if you have Roxio's Toast you can use the included "TiVo Transfer" application to download your files. Either way you end up with a file on your Mac that is encrypted. So let's decrypt them.
Assuming you have followed all my directions you should have a copy of tivodecode loaded on your Mac. Now all you need is an Automator Workflow to convert all the files. Not one at a time, but in a batch so you can set it running before you go to bed.
Open up the Automator application and create a new Workflow
In the column at the left you will need to select "Files & Folders" icon on the left then drag the "Ask for Finder Items" into the window pane on the right. In the "Prompt" section just type in "Choose a Tivo file(s)" and fill the folder location you normally use when you download your Tivo files. To handle multiple files make sure that the Type is set to "Files" and "Allow Multiple Selection" box is checked.
In order to deal with multiple files we need to assign them as variables. Select "Utilities" from the Library and drag "Set Value of Variable" to the right window pane. In the Variable box create a new variable. I called mine "Tivo_File".
Just as an explanation, the variable "Tivo_File" will be set to the file or files you select manually when you run the action. The value of the variable will be the full name of the file including path.
example:
.../TiVo Files/Supernatural_Hunteri_Heroici_111 KSTWDT_1363233538.TiVo
This is a very important point that we will have to deal with later in the shell script. The tivodecode application needs both the path to the file and the file name. Now that the variable is set we need to use it.
Again select "Utilities" from the Library and drag "Get Value of Variable" to your script. It seems odd, and you would think the computer should remember the variable because you just set it, but that's the way scripting works. Especially when dealing with multiple files. Make sure that the Variable is set to "Tivo_File" or whatever name you choose in the set variable value step.
Another important point is to make sure the "Ignore this action's input" check-box is checked in the options tab since our input is the variable itself.
Now that we have our variable we need to run a shell script to decode it. Grab the "Run Shell Script" action from utilities and move it to the Window pane on the right. Make sure the "Shell" is set to "/bin/bash".
The first thing we do is start a loop to process each of the files you selected. I have titled my loop counter as the letter "i".
for i in "$@"
do
After we start our loop we need to decode our variable and just grab the file name without the full path information in front of it. To do that I choose to use the UNIX awk command. There are a lot of ways to do this but this one works. The assumption here is that your file name extension has .TiVo at the end. Or to be more exact, it has a dot "." and an extension at the end of the file name. I've set the file name to a script variable called "fname".
fname=`echo $i | awk -F"/" '{print $NF}'| awk -F"." '{print $1}'`
After we have the file name we need to run tivodecode.
tivodecode -m 1234567890 -o "/MacHD/Users/Username/Movies/$fname.mpg" "$i"
Remember to insert your real MAK address into the command where I have put "1234567890". Also insert the real path to your output file. The output file will be the same as your downloaded TiVo file name but with an ".mpg" extension. The "$i" at the end of of the statement is the full path & filename. Make sure to inlude the quotes as I have shown above.
Since that's all the processing we need to close the loop by adding "done" at the end of the script. This is how your script should look.
Since that's the last step here's a copy of the entire automator action
You can check your script at this point by hitting the run button at the top. If it all works as planned you are ready to save your Automator Workflow as an executable app. Make sure it's saved as an application in the "File Format" drop down menu.
Happy converting and I hope this answers the question of how to process multiple input files in a single script.