Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diniscorreia

macrumors member
Original poster
Jun 23, 2003
45
0
Portugal
Hi all,

I'm trying to tweak a folder action script to something I'm not even sure it's possible. I'm using a script provided by iFlicks - a video utility - that automatically processes movie files added to the folder.

Here's the original script:

Code:
on adding folder items to thisFolder after receiving addedItems
	
	repeat with movieFile in addedItems
		tell application "iFlicks"
			import movieFile without gui
		end tell
	end repeat
	
end adding folder items to

On that same folder, I'll also be adding subtitle files (.srt). The movie files will be added first, though. However, I can only have the movie file sent to iFlicks after the .srt file exists. I need to modify the script so that it only runs when an .srt file is added *and* when there is already a .mov file (or any other video extension) with the same name of the .srt.

This is what I'm trying:

Code:
-- Check the name extension
-- NOTE: do not use periods (.) with the items in the name extensions list 
-- eg: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg", ".jpeg"} 
property extensionList : {"srt"}

on adding folder items to thisFolder after receiving addedItems
	repeat with thisItem in addedItems
		tell application "Finder"
			-- CHECK TO SEE IF THE SUBTITLE FILE EXISTS
			if (the name extension of the thisItem is in the extensionList) then
				
				my check_subs(thisItem, thisFolder)
				
			end if
		end tell
	end repeat
end adding folder items to

on check_subs(thisItem, thisFolder)
	
	tell application "Finder"
		
		set file_extension to the name extension of thisItem
		set the file_name to the name of thisItem
		
		if (exists document file file_name of thisFolder and document file name extension is "avi") then
			
			tell application "iFlicks"
				import file_name & ".avi" without gui
			end tell
			
		end if
	end tell
	
end check_subs

I really have no idea how to check for a file with a specific name *and* extension.

Any ideias? :confused:

Thanks in advance!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.