Hello, I want to make a Folder Action that waits until the file has transferred over, checks the name extension of the file, and then duplicates the file over to a specific folder. Here is what I have so far:
on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
set Was to 0
set isNow to 1
repeat while isNow ≠Was
set Was to size of (info for f)
delay 10
set isNow to size of (info for f)
end repeat
end repeat
tell application "Finder"
if name extension of theItems is "mov" then
duplicate theItems to folder "HD Files" of folder "SVR" of disk "MEDIA" with replacing
else if name extension of theItems is "qt" then
duplicate theItems to folder "SD Files" of folder "SVR" of disk "MEDIA" with replacing
end if
end tell
end adding folder items to
Can’t seem to get this to work.
Also, is there anyway to filter files based on their video dimensions ( ex. 1920x1080 or 720x480)
Thanks for your help.
Chad
Browser: Safari 537.85.10
Operating System: Mac OS X (10.8)
If I understand well, the problem is that you are asking the Finder to check that the name extension of a list of aliases is a given value.
As far as I know the app is able to get the name extension of a single file, not the one of a list of files.
Try to use :
on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
set Was to 0
set isNow to 1
repeat while isNow ≠Was
set Was to size of (info for f)
delay 10
set isNow to size of (info for f)
end repeat
tell application "Finder"
set nameExt to name extension of f
if nameExt is "mov" then
duplicate f to folder "HD Files" of folder "SVR" of disk "MEDIA" with replacing
else if nameExt is "qt" then
duplicate f to folder "SD Files" of folder "SVR" of disk "MEDIA" with replacing
end if
end tell
end repeat
end adding folder items to
I will repeat what I wrote very often : info for is deprecated so it’s not a good idea to use it
So I think that it would be better to use :
on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
set Was to 0
set isNow to 1
repeat while isNow ≠Was
tell application "System Events" to set Was to size of f
delay 10
tell application "System Events" to set isNow to size of f
end repeat
tell application "Finder"
set nameExt to name extension of f
if nameExt is "mov" then
duplicate f to folder "HD Files" of folder "SVR" of disk "MEDIA" with replacing
else if nameExt is "qt" then
duplicate f to folder "SD Files" of folder "SVR" of disk "MEDIA" with replacing
end if
end tell
end repeat
end adding folder items to
As far as I know, neither the Finder nor System Events are able to grab the video size of a file.
I guess that we may get this info in the file’s metadatas but it’s an other story.
Yvan KOENIG (VALLAURIS, France) mercredi 12 novembre 2014 20:39:16