Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kenshodin

macrumors newbie
Original poster
Jun 22, 2016
1
0
Hello All!

I am very new with apple script, and I am having two issues I would love some help with the script below.

My goal is to copy the two "Folders" from two separate directory locations into one newly created folder on the desktop that is date stamped.

Example:

1. Create new folder called: NewTestFolder(date)
2. Duplicate Macintosh HD:Users:User: Desktop:TestFolder to NewTestFolder
3. Duplicate Macintosh HD:Users:User: Desktop:TestFolder2 to NewTestFolder

End result is "TestFolder" & "TestFolder2" are copied to the newly created "NewTestFolder(date)"


Here is what I have so far...

Code:
tell application "Finder"
    set p to path to desktop
    make new folder at p with properties {name:"NewTestFolder"}
    duplicatefolder "Macintosh HD:Users:User:Desktop:TestFolder" tofolder "Macintosh HD:Users:apple:Desktop:NewTestFolder"
    duplicatefolder "Macintosh HD:Users:User:Desktop:TestFolder2" tofolder "Macintosh HD:Users:apple:Desktop:NewTestFolder"
end tell

Thank you very much for your time!
 
You don't mention what your problems are, however, using a little guess work I think something like this should do the job:

Code:
tell application "Finder"
  
    set p to path to desktop
  
    --get the date: I use a little shell script to do this because I find AppleScript's
    --native method too fiddly
    set theDate to do shell script "date \"+%Y-%m-%d\""
  
    --you might want to think about what you want the script to do if the
    --folder already exists
    set theNewFolder to make new folder at p with properties {name:"NewTestFolder (" & theDate & ")"}
  
    --nb. If the folder already exists then we replace it. Just knock the "with replacing"
    --off the end if you don't want that to happen. If you do that, you should probably think about
    --what to do if the folder alreday exists
    duplicate folder "Macintosh HD:Your:Path:Here:" to theNewFolder with replacing
    duplicate folder "Macintosh HD:Your:Other:Path:Here:" to theNewFolder with replacing
  
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.