Hi There!
I am trying to figure out if there is an easy way to do this in AppleScript. I am familiar with the language but don’t use it often enough to get it to this kind of detail.
I have folders on a drive, These folders are all “job” numbers, in each job numbered folder there are documents (images, indesign files, word docs, etc.) Now what I am trying to do is have a script look in the job folders and see if anything has been modified inside the folder within a certain number of days, if it has…do A, if not do B.
Make sense?
/MainFolder/JobNumber/JobDocs.doc
Here is what I have so far, I can get if the folders inside the main folder have been modified, but what is the best way to go into the folders that are going to be archived, and look to see if any folders or files have been modified under the same time criteria? These folders can go 5 or 6 folders deep. Thanks!
gets the current date
set myDate to current date
sets the date of what i want to archive (anything befroe this date
set myNewDate to myDate - (365 * days)
tell application "Finder"
--chosse to root folder of where the job folder are stored
set source_folder to (choose folder)
--getting information from the folders inside the root folder
set fls to every item in source_folder
repeat with x in fls
set nm to name of x
set d to modification date of x
set yr to year of d as string
set mth to (month of d as number) as string
if length of mth is 1 then set mth to "0" & mth
set dy to day of d as string
if length of dy is 1 then set dy to "0" & dy
set h to hours of d as string
if length of h is 1 then set h to "0" & h
set m to minutes of d as string
if length of m is 1 then set m to "0" & m
set s to seconds of d as string
if length of s is 1 then set s to "0" & s
set dt to yr & mth & dy & "_" & h & "-" & m & "-" & s as string
--sets the soruce folder path to a string for a later move command
set asSource_folder to source_folder as string
--sees if the date is less than the target date
if d < myNewDate then
--choose the destination folder (archive folder)
set destination_folder to (choose folder)
--move it to the archive folder
move folder nm of folder asSource_folder to folder destination_folder
else
--nothing to do
end if
end repeat
end tell