TV Show file Sorting Apple Script

Discussion in 'Mac Programming' started by BrianDowner, Feb 15, 2009.

  1. macrumors newbie

    Joined:
    Feb 15, 2009
    #1
    The purpose of this Script is to sort TV shows into Folders of the same name. I have to use the first word of the file name to identify the TV show. That part works great. The script is unable to identify the destination folder with the same name. I've racked my brain and googled the world to solve this but have come up with nothing. If any one can help I would very much appreciate it.

    The problem I'm having is on this line:


    Code:
    move selection to folder whose name begins with theCurrentValue of disk "tv"
    
    See what happens:



    Full Script:

    Code:
    set tvShowFirstWordOfFileName to {"Heroes", "Psych", "Battlestar", "Lost", "Ghost", "Monk", "The", "How", "Smallville"}
    
    
    tell application "Finder"
    	
    	repeat with theCurrentValue in tvShowFirstWordOfFileName
    		
    		set testFile to {}
    		
    		try
    			set testFile to (some file of disk "tv" whose name begins with theCurrentValue)
    		end try
    		
    		if exists testFile then
    			select (every file of disk "tv" whose name begins with theCurrentValue)
    			move selection to folder whose name begins with theCurrentValue of disk "tv"
    		end if
    		
    	end repeat
    	
    end tell
    
     

Share This Page