Hello all,
I just realized the amazing ability that applescript has for getting rid of mundane tasks.
At work i have to perform a weekly “Recap” of what was created over the past week. I have been trying to make this a one click operation.
I need the script to copy all files (in a specific folder) modified or created over the past week and that are certain file types (aif,mp3,wav,mov etc).
Since I only understand the basic basics i have been looking to other peoples scripts for specific lines. I used parts of Jeff Fischer’s “Copy folder tree” to help me create this so far. I have also demolished some scripts for sorting emails by date.
since i am still new to this i will explain it in straight english first cause its easier for me and then ill put the code thurr too.
so in my script i have it set up that it
1-sets the date to my format,
2-makes a new folder,
3-begins the copy folder tree,
4-asks user to set the source folder with a prompt,
5-sets the destination to the prechosen directory,
6-copies all files that meet the requirements of filetype and that were modified within
8 days of the current date,
7-copies the selections to the Destination,
8-changes the name of the destination folder to “Recap-(todaysDate)”
9-Tells me it Recap’d the Folder
here are my problems then ill paste the code–
1-anything selected on the desktop gets copied into the destination
2-when i pick big directories to copy the selected filetypes from, it either doesnt work or copies the selected files over and over into every folder within the entire directory.
How can i make it so it only copies folders in the source that have these modified files in them?? and so it doesnt paste the modified files into every other folder of the destination? the source folder i have is a big folder, fluctuating bwtn 20-40GB and even if it finds one files modified within in it, when it copies that and puts it in every empty folder at the destination it gets messy (and big).
anyone who can help at all with any of this is awesome and i appreciate you making it this far in my post!
k, here is the script-im sure it looks messy and awful but thank you-
elijah b torn
http://theycontrol.us/sarge
property gFileTypes : {“aif”, “mov”, “mp3”, “mpg”}
tell application “Finder”
set todaysDate to current date
set {m, d, y} to {month, day, year} of todaysDate
set monthList to {January, February, March, April, May, June, ¬
July, August, September, October, November, December}
repeat with i from 1 to 12
if m = (item i of monthList) then
set monthString to text -2 thru -1 of ("0" & i)
exit repeat
end if
end repeat
set dayString to text -2 thru -1 of ("0" & d)
set yearString to text -2 thru -1 of (y as string)
set myDate to monthString & "." & dayString & "." & yearString
set olddate to ((current date) - (8 * days))
make new folder of "Macintosh HD:Users:Peoples:holdingtank:Recap"
(*begin Copy Folder Tree*)
set tSourceFolder to choose folder with prompt "Choose a folder structure to duplicate"
if tSourceFolder is false then return "User Cancelled"
set tDestFolder to "Macintosh HD:Users:Peoples:holdingtank:Recap:untitled folder"
my copyItems(tSourceFolder, tDestFolder)
end tell
on copyItems(pSourceFolder, pDestFolder)
tell application “Finder”
set olddate to ((current date) - (8 * days))
set tSourceFolderName to name of pSourceFolder as string
make new folder at pDestFolder with properties {name:tSourceFolderName}
set tNewDestFolder to (folder tSourceFolderName of folder pDestFolder) as alias
-- copy or move over files of the specified type(s)
set tSelectedFiles to {every file of folder pSourceFolder whose name extension is in gFileTypes and modification date is greater than olddate}
if tSelectedFiles ? {} then
select {every file of folder pSourceFolder whose name extension is in gFileTypes and modification date is greater than olddate}
copy the selection to folder tNewDestFolder
end if
-- copy over the folders, calling this handler recursively
set tFolders to (every folder of pSourceFolder)
repeat with tThisFolder in tFolders
my copyItems(tThisFolder as alias, tNewDestFolder as alias)
end repeat
end tell
end copyItems
tell application “Finder”
close windows
open folder "Macintosh HD:Users:Peoples:holdingtank:Recap:untitled folder"
set temp to "Recap-"
set textEntered to temp & myDate
set newfoldername to textEntered
set name of folder "Macintosh HD:Users:Peoples:holdingtank:Recap:untitled folder" to textEntered
display dialog "Recap'd the Holding Tank."
beep
end tell
(SHGb02+14a-)