Checkbox for multiple folders that are going to be created

Hey guys,

I’m a serious noob and besides that german (excuse my english, please), but working on a script right now to create multiple folders for project management.
Right now my script looks like this:


set Ordner to choose folder with prompt "In welchem Ordner soll das Projekt erstellt werden?"
set Fortlaufend to text returned of (display dialog "Fortlaufende Nummer? (ex.20101208)" default answer ¬
	"Projektnummer" buttons ¬
	{"Ja!", "Nein. Du Otto."} default button 1 ¬
	)

set Ordnername to text returned of (display dialog "Wie heisst das Projekt? (Kunde_Marke_Projekt_Version)" default answer ¬
	"bezeichnung" buttons ¬
	{"Ja!", "Nein. Du Otto."} default button 1 ¬
	)

set Projekt to Fortlaufend & {"_"} & Ordnername as item
set Eingang to Fortlaufend & {"_Incoming"} as item
set Ausgang to Fortlaufend & {"_Outgoing"} as item
set Arbeit to Fortlaufend & {"_Work"} as item
set DreiD to Fortlaufend & {"_3D"} as item
set Rohmaterial to Fortlaufend & {"_Rohmaterial"} as item
set Audio to Fortlaufend & {"_Audio"} as item

tell application "Finder"
	set ProjektOrdner to make new folder at Ordner with properties {name:Projekt}
	set EingangsOrdner to make new folder at ProjektOrdner with properties {name:Eingang}
	set AusgangsOrdner to make new folder at ProjektOrdner with properties {name:Ausgang}
	set ArbeitsOrdner to make new folder at ProjektOrdner with properties {name:Arbeit}
	set DreiD_Ordner to make new folder at ArbeitsOrdner with properties {name:DreiD}
	set RohmaterialOrdner to make new folder at ArbeitsOrdner with properties {name:Rohmaterial}
	set AudioOrdner to make new folder at ArbeitsOrdner with properties {name:Audio}
	set everyones privileges of Ordner to read write
	set everyones privileges of ProjektOrdner to read write
	set everyones privileges of EingangsOrdner to read write
	set everyones privileges of AusgangsOrdner to read write
	set everyones privileges of ArbeitsOrdner to read write
	set everyones privileges of DreiD_Ordner to read write
	set everyones privileges of AudioOrdner to read write
	
end tell

set Projektliste to choose file with prompt "Wo ist die Projektliste? (Projektliste.rtf)"
tell application "TextEdit"
	open Projektliste as alias
	make new word at end of front document with data return & Projekt
	save front document
	close front document
end tell

So, it asks me where the folders should be created, asks for a name. What I want to achieve is that I’m able to choose which folders got to be created - a list of folders and subfolders with checkboxes is what I have in mind.
Can someone please tell me how to implement a function like this or point me into the right direction? That would be awsome.
PS: I have a second question, but it’s not very important: The project numbers are YYYYMM plus ascending numbers and right now I have to manually write those numbers - is it possible to “read” the year and month and add a number based on what has been written last into the “projektliste.rtf”, where I keep track of all projects?

Thx!

AppleScript: 2.1.2
Browser: Firefox 14.0.1
Operating System: Mac OS X (10.6)

Hi,

welcome to MacScripter.
Try this script. It prompts the user to choose the subfolders of the project folder
and “ if the work folder has been chosen “ then the subfolders of the work folder.
The script uses the shell to create the folders and to change the privileges.

Two notes:
If the file “Projektliste” was plain text (.txt), the information could be added without TextEdit
I removed the impolite button titles :wink: but for better understanding I kept the german variable names.


property UnterOrdnerListe : {"Incoming", "Outgoing", "Work"}
property WorkUnterOrdnerListe : {"3D", "Rohmaterial", "Audio"}

set Ordner to choose folder with prompt "In welchem Ordner soll das Projekt erstellt werden?"
set Fortlaufend to text returned of (display dialog "Fortlaufende Nummer? (ex.20101208)" default answer ¬
	"Projektnummer" buttons {"Abbrechen", "Weiter"} default button 2)

set Ordnername to text returned of (display dialog "Wie heisst das Projekt? (Kunde_Marke_Projekt_Version)" default answer ¬
	"bezeichnung" buttons {"Abbrechen", "Weiter"} default button 2)

set UnterOrdner to choose from list UnterOrdnerListe with prompt "Erste Ebene der Unterordner wählen (Mehrfachauswahl möglich)" with multiple selections allowed
if UnterOrdner is false then return
if UnterOrdner contains "Work" then
	set WorkUnterOrdner to choose from list WorkUnterOrdnerListe with prompt "Unterordner des Work-Ordners wählen (Mehrfachauswahl möglich)" with multiple selections allowed
	if WorkUnterOrdner is false then return
else
	set WorkUnterOrdner to {}
end if

set {year:yr, month:mn} to (current date)
set Datum to (yr as text) & text -2 thru -1 of (((mn as integer) + 100) as text)
set Prefix to Datum & "_" & Fortlaufend & "_"

set {TID, text item delimiters} to {text item delimiters, ","}
set OrdnerStruktur to quoted form of POSIX path of Ordner & "/" & quoted form of (Prefix & Ordnername) & "/{"
repeat with einOrdner in UnterOrdner
	set contents of einOrdner to Prefix & einOrdner
end repeat
set OrdnerStruktur to OrdnerStruktur & UnterOrdner as text
if WorkUnterOrdner is not {} then
	repeat with einOrdner in WorkUnterOrdner
		set contents of einOrdner to Prefix & einOrdner
	end repeat
	set OrdnerStruktur to OrdnerStruktur & "/{" & (WorkUnterOrdner as text) & "}"
end if
set OrdnerStruktur to OrdnerStruktur & "}"
set text item delimiters to TID
do shell script "mkdir -p " & OrdnerStruktur
do shell script "chmod -R o=rw " & quoted form of POSIX path of Ordner

set Projektliste to choose file with prompt "Wo ist die Projektliste? (Projektliste.rtf)"
tell application "TextEdit"
	open Projektliste as alias
	make new word at end of front document with data return & Prefix & Ordnername
	save front document
	close front document
end tell


Whoah, great! Thx so much! Looks good - though I’m not sure if I totally understand what is happening in that script… :wink:
Will check this as soon as possible…