Video File Sorting - Need Help

Looking at it, it seem it should work. but it doesn’t. The idea is to pass file names through an array and the matches will be moved to a specific folder. Any help you can give would be great.

try
	tell application "Finder"
		set Keepers to {"Stargate", "Heroes"}
		set the_files to every item of entire contents of folder "∞ New Downloads ∞" of disk "Videos"
		repeat with this_file in the_files
			if this_file begins with Keepers then move this_file to folder "∞ To Be Sorted ∞" of disk "Videos"
		end repeat
	end tell
end try

Hi,

apart from having posted into the wrong forum. :wink:

It doesn’t work because of 2 reasons.
¢ The syntax begins with cannot be used with a list
¢ this_file is a file (an object), it cannot be compared with a string or a list

by the way: while developing scripts remove any try blocks to get error messages

Try something like this


set Keepers to {"Stargate", "Heroes"}
tell application "Finder"
	set the_files to every item of entire contents of folder "∞ New Downloads ∞" of disk "Videos"
	repeat with this_file in the_files
		if name of this_file is in Keepers then move this_file to folder "∞ To Be Sorted ∞" of disk "Videos"
	end repeat
end tell

or


tell application "Finder"
	set the_files to every item of entire contents of folder "∞ New Downloads ∞" of disk "Videos"
	repeat with this_file in the_files
		if name of this_file begins with "Stargate" or name of this_file begins with "Heroes" then move this_file to folder "∞ To Be Sorted ∞" of disk "Videos"
	end repeat
end tell

Thank you now I can stop beating my head against the wall.

Simply moved the topic to the appropriate forum :wink: