I have been working on an applescript droplet that scans through the files (also recursively through folders) dropped onto it and deletes those whose file types and creator types match up to those in lists. The program has no problems that I’ve come across of after several tests. I am trying to add an “on open” routine that peforms the scanning/deleting action when double-clicked, actually at a certain time, where it monitors the time and runs when idle. I don’t have any problems with the time checking. However the problem is that I don’t know how to specify a folder as a variable to be processed as if it were dropped onto the app. How do I specify a folder as a variable where I can use code like
"count of these_items"
which I use with
"repeat with 1 to the count of these_items"
to go through all the folders and find files inside (recursive folders also). Thanks in advance for any help.
- Brian
My suggestion is as follows:
Create the droplet which processes the folder (myFolder in the example) and save it.
Then create a separate application which is a stay-open application (never show startup screen is best) . This application should contain the idle handler and time checking process followed by the code below:
-- define myFolder to be the folder to process
my processFolder(myFolder) -- call a handler to process the the folder
on processFolder(myFolder)
ignoring application responses
tell application "Processing Droplet" -- the name of the droplet to process folder
launch
open ({alias myFolder})
end tell
end ignoring
end processFolder
When the idle handler activates it should “open” the “Processing Droplet” as if the folder myFolder was dropped onto it.
Hope this is helpful
Paul,
Thanks for the idea. I’ll work on it and let you know how it comes out.
Here’s the code for the second program. It works perfect without the time checking, but I can’t figure out what’s wrong with the time checking. It’s identical to another copy in a different program where it works. Any idea what’s wrong with the time checking? (time check is for 9:55 AM)
on idle
if ((characters 1 through 2 of time string of (current date) contains "9") and ¬
(characters 3 through 6 of time string of (current date) contains "55") and ¬
(characters 9 through 10 of time string of (current date) contains "A")) then
tell application "Search and Destroy v1.0.5"
launch
open {alias "Macintosh HD:Simulation 5:"}
end tell
end if
end idle
Characters 3 through 6 of time string of current date will never contain “55”.
They may contain “two different” 5’s but never “55”.
I think that the simplest solution is to accept a time of 9:56:00 AM.
To do this change your code to that below
on idle
if ((characters 1 through 2 of time string of (current date) contains "9") and ¬
(characters 3 through 6 of time string of (current date) contains "5") and ¬
(characters 3 through 6 of time string of (current date) contains "6") and ¬
(characters 9 through 10 of time string of (current date) contains "A")) then
tell application "Search and Destroy v1.0.5"
launch
open {alias "Macintosh HD:Simulation 5:"}
end tell
end if
end idle
This should launch your application at 9:56:00 PM
Good Luck !
I just love when common sense strikes me out of the ordinary. Remember how was checking the time in such a complicated way with three lines of code checking each part of the time string. Now all I use is this line of code which works perfectly. The idea didn’t strike me though until I read your last message, though not sure exactly how or what did it. Thank you. Here’s the simple checking code:
if ((time string of (current date) contains "9:49") and (time string of (current date) contains "P")) then
Thank you for so much help you’ve given me.