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

Posted on Jul 24, 2023 10:40 AM

Reply

Similar questions

4 replies

Jul 24, 2023 11:15 AM in response to greeny62

I would encourage seeking an existing commercial customer relationship management (and probably billing) system, rather than building your own unique system, one issue and one requirement and one bugfix at a time.


But... Here's a zsh script that prompts for a string, and then creates X, Y, and Z subdirectories under YYYY_MM_DD Project on a mounted volume named NO NAME:

#!/usr/bin/env zsh
PROJECT_NAME="$(osascript -e 'text returned of (display dialog "Project?" default answer "No Project Name Specified")')"
PATH_AND_DATE="/Volumes/NO NAME/"$(date "+%Y_%m_%d")
echo "Creating directories for $PATH_AND_DATE $PROJECT_NAME"
mkdir -p "$PATH_AND_DATE $PROJECT_NAME/X"
mkdir -p "$PATH_AND_DATE $PROJECT_NAME/Y"
mkdir -p "$PATH_AND_DATE $PROJECT_NAME/Z"


I leave it to the reader to customize this homegrown CRM system...

Jul 25, 2023 2:56 AM in response to MrHoffman

thanks a lot for your advice and time


"I would encourage seeking an existing commercial customer relationship management (and probably billing) system "


you are greatly over estimating our scale... we do small modelmaking / prop etc. projects and we use a standard set of folders inside each project folder. Our jobs vary a lot so the folder structure gets adapted and changed all the time.

I merely try to make creating such an initial project folder and its start-up-content a tad more convenient.


thx Jo

Jul 25, 2023 8:48 AM in response to greeny62

greeny62 wrote:

thanks a lot for your advice and time

"I would encourage seeking an existing commercial customer relationship management (and probably billing) system "

you are greatly over estimating our scale... we do small modelmaking / prop etc. projects and we use a standard set of folders inside each project folder. Our jobs vary a lot so the folder structure gets adapted and changed all the time.


If anything, you’re probably underestimating your current scale 😉 and where this is all headed particularly when you’re good at building models and props. Incrementally creating your own IT environment does work, though.

Create a folder with the current date as name (Applescript)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.