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

alptkz

macrumors newbie
Original poster
Feb 26, 2009
26
0
hi all.

I'm trying to write a script (very little experience here) for a folder action that will label in blue all the video files in my Movies folder that have never been played.

I find myself way over my head on this. Can anyone help me out ?
 

LtRammstein

macrumors 6502a
Jun 20, 2006
570
0
Denver, CO
Have you looked into the AppleScript iTunes library? I belive there's an element in there that would allow you to do it, but not sure (on a PC in a lab right now).

You might need to also teach yourself AppleScript before you go any further. I recommend you search Google for any tutorials that might help out.
 

alptkz

macrumors newbie
Original poster
Feb 26, 2009
26
0
I looked in the iTunes dictionary, but I'm not really sure what to look for. In fact, why is iTunes involved at all ?

The way I picture it, the script would check in a folder if the video files (all avi actually) have been played or not, and if not, assign a blue label, if yes then no label.

The question is, is there a way to check whether the file was played (or opened) or not. If not, I'm guessing I'd need to do it in 2 scripts. One that watches for added files and labels them as soon as they are added. The 2nd would remove the label as soon as the file is played.

Am I looking at this wrong ?
 

alptkz

macrumors newbie
Original poster
Feb 26, 2009
26
0
Ok I've gone for option 2 as it seems more straight forward. I've created succesfully one script that labels any video file added to my Movies folder. It looks like this:
on adding folder items to this_folder after receiving these_items
tell application "Finder"

repeat with myFile in these_items
--display dialog myFile as string
if the name extension of myFile is in {"mpg", "mpeg", "avi", "mov", "mp4", "avi", "wmv"} then
set label index of myFile to 4
end if

end repeat
end tell
end adding folder items to

That works great, but it doesn't include subfolders. How can I do that?

Then I created a 2nd script that would remove the label when a video file is opened. It doesn't work though. This is what I wrote so far:
on open these_items
tell application "Finder"

if the name extension of these_items is in {"mpg", "mpeg", "avi", "mov", "mp4", "avi", "wmv"} then
set label index of these_items to 0
end if

end tell
end open

I'm guessing my problem is on the first blue line, I just don't know what to use there.

Any ideas ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.