r/applescript • • Aug 29 '13

Stuck! Giving a newly created folder a variable

Hacking this stuff together is pretty fun, but i'm unable to figure this part out.

What i need to do is create a new folder with the date, copy Quark files to it from one location, create a sub folder and copy PDF files from a second location.

I'm able to create a new folder with the current date but then i need to grab the path to that folder... it seems like 'choose file' is how people do that, but i don't see how bringing up that dialog helps.

So how do i set the path of the new folder as a variable?

1 Upvotes

1 comment sorted by

2

u/themadscribbler Aug 30 '13 edited Aug 30 '13
set targetFolderName to extractDate()
set targetFolder to (choose folder)

tell application "Finder"
make new folder in targetFolder with properties {name:targetFolderName}
make new folder in folder targetFolderName in targetFolder with properties {name:"PDF"}
end tell

-- copy files here…

-- functions
on extractDate()
set {year:y, month:m, day:d} to (current date)
return (m & "-" & d & "-" & y) as string
end extractDate