Ok here is what I want to do.
A script to kick in when ever a new “File” shows up that is in AVI format comes into a folder on my 2nd hard drive.
Then to load VisualHub and then run this script that I have made for the folder.
on adding folder items to this_folder after receiving added_items1
set avi to "avi"
tell application "VisualHub" to activate
tell application "VisualHub" to set VisualHub to load script (scripts path of main bundle & "/automation.scpt" as POSIX file)
set everyavi to every file whose name extension is avi in added_items1
tell VisualHub
AddFiles(everyavi)
LoadSettings("OS X:Users:michaelcrossland:Documents:Settings.vhub")
SetSaveLocation("OS X:Users:michaelcrossland:Movies")
StartConversion()
QuitApp()
end tell
end adding folder items to
Ok I took the top part of the code from a stock one that comes with the OS.
The next part is my doing, then the code down to 5 is right out of the How to and then 5 is mine and then the rest is right out of the guide.
Now could some one point out to me why this script does not work when I copy a new file into the folder it setup on?
I am trying my d*mnedest to learn this stuff the right way.
Any help will make my day.
Michael
only the Finder knows about name extensions of files, and
unfortunately you can not use the whose filter with a simple list.
Try this
on adding folder items to this_folder after receiving added_items1
set avi to "avi"
tell application "VisualHub" to activate
tell application "VisualHub" to set VisualHub to load script (scripts path of main bundle & "/automation.scpt" as POSIX file)
set everyavi to {}
repeat with oneItem in added_items1
tell application "Finder" to if name extension of oneItem is avi then set end of everyavi to contents of oneItem
end repeat
tell VisualHub
AddFiles(everyavi)
LoadSettings("OS X:Users:michaelcrossland:Documents:Settings.vhub")
SetSaveLocation("OS X:Users:michaelcrossland:Movies")
StartConversion()
QuitApp()
end tell
end adding folder items to
Thank you for that heads up.
I about kicked myself when I sew that the this_folder is in fact a variable.
Thanks for showing me that in back handed way.
And thanks for the heads up on the finder part.
here is what I end up with.
on adding folder items to this_folder after receiving added_items1
set avi to "avi"
tell application "VisualHub" to activate
tell application "VisualHub" to set VisualHub to load script (scripts path of main bundle & "/automation.scpt" as POSIX file)
set everyavi to {}
repeat with oneItem in added_items1
tell application "Finder" to if name extension of oneItem is avi then set end of everyavi to contents of oneItem
end repeat
tell VisualHub
AddFiles(everyavi)
delay 60
StartConversion()
QuitApp()
end tell
end adding folder items to
I had to take out the loading of a settings file as it would load it up but the window would never close it would just sit there saying loading.
And i added the delay because it take a bit for VisualHub to get running.
That and found that if I am around it give me the time to set the only part of the setting that will not stay after a restart of the app.
Thank you for teaching me to open my eyes and to use my brain more when looking at the code.