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

tarek01

macrumors newbie
Original poster
Sep 6, 2009
8
0
This is an Applescript that automatically plays a folder of QuickTime movies in succession and it works flawlessly (Credit goes to macdosth for creating the script):

Code:
tell application "QuickTime Player"
	-- get the list of movie files to be played
	tell application "Finder"
		set myfolder to "Mac HD:Movies"
		set filelist to list folder myfolder
	end tell
	-- play the movie files one after another
	set myfolder to "Mac HD:Movies:"
	repeat with movie1 in filelist
		-- get the full path to the movie
		set fullmovie1 to myfolder & movie1
		-- play the movie
		open fullmovie1
		present document 1 scale screen
		-- wait until movie is done
		repeat until (get done of document 1)
		end repeat
		-- pause for a few seconds before next movie
		-- (delay of greater than 2 seconds doesn't seem to work)
		delay 2
		-- close the played movie
		close document 1
	end repeat
end tell

What I would like to do is add a prompt that asks which folder contains the movies that are to be played. Here's the modified code, but it doesn't work. Can anyone figure out what's wrong?

Code:
tell application "QuickTime Player"
	-- get the list of movie files to be played
	tell application "Finder"
		set myfolder to (choose folder with prompt "Select the folder containing QuickTime moves...")
		set filelist to list folder myfolder
	end tell
	-- play the movie files one after another
	set myfolder to myfolder --unsure about this line
	repeat with movie1 in filelist
		-- get the full path to the movie
		set fullmovie1 to myfolder & movie1
		-- play the movie
		open fullmovie1
		present document 1 scale screen
		-- wait until movie is done
		repeat until (get done of document 1)
		end repeat
		-- pause for a few seconds before next movie
		-- (delay of greater than 2 seconds doesn't seem to work)
		delay 2
		-- close the played movie
		close document 1
	end repeat
end tell
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Try changing the the choose folder line to:

Code:
set myfolder to (choose folder with prompt "Select the folder containing QuickTime moves...") as string

I still get errors though. For example what if there is a .DS_Store file in the folder?
 

tarek01

macrumors newbie
Original poster
Sep 6, 2009
8
0
Awesome! I suspected it was a tiny fix. Thanks robbie!

It still needs tweaking to add the ability to detect the file type. But even so, this little script far outweighs its imperfections if you apply it to folders dedicated to contain only video files. Great for viewing tutorials containing dozens of MOVs!
 

tarek01

macrumors newbie
Original poster
Sep 6, 2009
8
0
Here's the modified working script. I removed the PRESENT MOVIE setting, just as a preference. Is it possible for it to play files inside sub-folders if the chosen folder ONLY contains folders?

Code:
tell application "QuickTime Player"
	-- get the list of movie files to be played
	set myfolder to (choose folder with prompt "Select the folder containing QuickTime moves...") as string
	set filelist to list folder myfolder
	-- play the movie files one after another
	repeat with movie1 in filelist
		-- get the full path to the movie
		set fullmovie1 to myfolder & movie1
		-- play the movie
		open fullmovie1
		-- wait until movie is done
		repeat until (get done of document 1)
		end repeat
		-- pause for a few seconds before next movie
		-- (delay of greater than 2 seconds doesn't seem to work)
		delay 2
		-- close the played movie
		close document 1
	end repeat
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.