Part 4: (Tutorial) Automating DVD Backup with FairMount, HandBrake and iTunes

Discussion in 'Apple TV and Home Theater' started by mac.jedi, Nov 14, 2008.

  1. macrumors 6502

    Joined:
    Feb 1, 2008
    Location:
    The O.C.
    #1

    Part 4: Automating DVD Backup with FairMount, HandBrake and iTunes

    Parts to this tutorial:
    Part 1: Introduction
    Part 2: Using AppleScript to Automate Ripping
    Part 3: Using a Batch Script to Automate HandBrake
    Part 4: TV Show Renamer Droplet
    Part 5: Add to iTunes and Auto-tag Script

    TV Show Renamer Droplet

    This script gets data from a plain text file you've named: show name_season#.txt (example: The Office_01.txt). This text file should contain only the episode names (one on each paragraph line) for this season only. This droplet will rename a sequential series of m4v files dropped on to it, so it is important your files are already named in order, they are usually already in order by the title number. The script will parse the file name and contents of the plain text file and rename the video files with the following file naming convention: Season#_Episode#(sequential)_Show Name_Episode Title.ext. The companion "Add to iTunes and auto-tag" script will parse these file names and insert the correct meta data automatically upon import to iTunes. You must save this file as an application in Script Editor in order to run the script when files are dropped on to it.


    Creating Your TV Show Renamer Droplet:

    1. Create a plain text file for each season you've encoded and want to rename.

      • a. Copy and paste an entire season of episode names into a txt file (one on each paragraph line). Only include the episode name.
        b. Save this as a plain text file and name it with the show name and season number (season three as shown in the following example): Show Name_03.txt

        [​IMG]

    2. Create the droplet
      • Select, copy and paste the script below into a new Script Editor document.

        Code:
        -- TV SHOW RENAMER SCRIPT
        (* This script gets data from a plain text file you've named: show name_season#.txt (example: The Office_01.txt). This text file should contain only the episode names (one on each paragraph line) for this season only. This droplet will rename a sequential series of m4v files dropped on to it, so it is important your files are already named in order, they are usually already in order by the title number. The script will parse the file name and contents of the plain text file and rename the video files with the following file naming convention: Season#_Episode#(sequential)_Show Name_Episode Title.ext. The companion "Add to iTunes and auto-tag" script will parse these file names and insert the correct meta data automatically upon import to iTunes. You must save this file as an application in Script Editor in order to run the script when files are dropped on to it. *)
        
        
        on open dropped_items
        	-- If you want to go directly to a certain folder every time, change the "default location alias" to the path to your episode list folder ("Macintosh HD:Users:Your Name:Documents:Episode Lists:)
        	set textInfo to choose file default location alias "Macintosh HD:Users:" with prompt "Choose file which contains the title list" without invisibles
        	set titleList to paragraphs of (read textInfo)
        	tell application "Finder" to set {name:txNm, name extension:txEx} to info for textInfo
        	set AppleScript's text item delimiters to "_"
        	
        	set txNm to text 1 thru ((count txNm) - (count txEx) - 1) of txNm
        	set showInfo to every text item of txNm
        	set txEx to "." & txEx
        	set AppleScript's text item delimiters to ""
        	set idx to 1
        	
        	repeat with i from 1 to count dropped_items
        		set {name:Nm, name extension:Ex} to info for (item i of dropped_items) as alias
        		if Ex is missing value then set Ex to ""
        		if Ex is not "" then
        			set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
        			set Ex to "." & Ex
        		end if
        		tell application "Finder" to set name of item i of dropped_items to item 2 of showInfo & "_" & text -2 thru -1 of ("00" & (idx as string)) & "_" & item 1 of showInfo & "_" & item i of titleList & Ex
        		set idx to idx + 1
        	end repeat
        end open
        

        Optional: Change the default location path to the path to your "Episode Lists" folder if you'd like the prompt to automatically open to that folder.

      • Save the script as an application: Choose File > Save As... > select Application from the File Format popup menu.
      • Verify that no options are checked.

        [​IMG]

      • Click Save.
    3. Rename your episode files
      • Select the files you want to rename. Note: It is important your files are already named in order, they are usually already in order by the title number.
      • Drag and drop the selected files onto the TV Show Renamer droplet.
      • Navigate and select the text file you created in Step 1 from the dialog box.

        [​IMG]

      • The episodes should automatically be renamed with the following file naming convention: Season#_Episode#(sequential)_Show Name_Episode Title.ext

        [​IMG]

    Go To Part 5: Add to iTunes and Auto-tag Script
     
  2. macrumors member

    Joined:
    Aug 1, 2008
    #2
    hi, the renaming part works for me, but i am having trouble with when the droplet renames the files out of order of what they were numbered, so it would name what is supposed to be the 3rd file, as the 10th episode, for example. help! thanks in advance!
     
  3. thread starter macrumors 6502

    Joined:
    Feb 1, 2008
    Location:
    The O.C.
    #3
    Log in

    Hi FLAVAH,

    I've found it helps if you put your episode files in a season folder (ex. Serenity_01). Then, switch to column view in the Finder. Select your season folder in column view and select all (CMD-a). Then, drag your files onto the droplet. I hope this helps!

    Also, make sure your episodes are already named in order. If the title was included during the HB encode, then they should already be in order.
     
  4. thread starter macrumors 6502

    Joined:
    Feb 1, 2008
    Location:
    The O.C.
    #4

Share This Page