Create a folder with the current date as name (Applescript)
Hi all
trying to create a small script that prompts for "client" and "project name" and then creates
on a shared volume named " SERVER " a folder named " YYYY_MM_DD client project " in my projects directory and then about 10 subfolders in that new folder that are always the same names no date or project in it...
client input
3D
bidding
etc
also I want to create a folder named " YYYY_MM_DD client project fotos " on a shared volume " MEDIA "
last not least I want an alias of the folder " /MEDIA/YYYY_MM_DD client project fotos " to be created in the project folder.
I came across this wonderful thread Create a folder with the current date as … - Apple Community
which is closed so I start here again.
In the mentioned script thread looks like a function is defined and listed below the main " Apple script program "
red menace posted this
tell application "Finder"
try
if exists Finder window 1 then
set thisPath to (the target of the front window) as alias
else
set thisPath to (path to desktop)
end if
on error errmess
log errmess
return
end try
end tell
set x to text returned of (display dialog "Folder name?" default answer the_perfect_datestring())
set fullPath to thisPath & x as text
tell application "Finder"
try
-- activate
if not (exists fullPath) then
set y to make new folder at thisPath with properties {name:x}
end if
-- open y
on error errmess
log errmess
end try
end tell
on the_perfect_datestring()
tell (current date) as «class isot» as string -- yyyy-mm-ddThh:mm:ss
return text 3 thru 4 & "_" & text 6 thru 7 & "_" & text 9 thru 10
end tell
end the_perfect_datestring
I tried the whole script and it works (Macbook pro i9 with 13.4.x MacOS )
but when I try to copy the "on" part into my script and try to "call" it from my main script I fail... I cannot figure out how to use the "function" and whatever I do I get an error
sorry its german, it says
" Finder got an error. Continuation impossible: the_perfect_datestring ."
I've used Apple script over the years to do little tasks, but never really learned it. So a very basic question:
For this kind of finder / filesystem related tasks, should I be using another language to do this ? javascript, python, shell script of some sort ?!?
Could anyone point me to a good documentation for Apple script or any alternative language ? Over the years I've found lots of Apple script tidbits and used them tp piece together some simple things, but never found a proper site dealing with the structure and syntax so I can look things like this up and try to learn a bit more .
Any hints for the current issue or "your better of doing it with "..." are much appreciated
kindest regards Jo
JMBP16_2021