Hallo Hans,
ja, im ersten Posting war nicht ersichtlich, dass von jedem Ordner eine Serie angelegt werden soll.
Hier nun das ausgebaute Script, welches gezwungenermassen etwas mehr Error-Handling betreffend der
Eingabe enthält: Ist der Starttag nicht grösser als die Gesamtzahl der Tage eines Monats?
Zählen Tag, Monat, Jahr insgesamt sechs Stellen? Ist jedes Zeichen eine Ziffer?
Das folgende Script als Droplet gesichert, erwartet, dass ein (oder mehrere) Ordner, dessen Name
mindestens neun Zeichen zählt, auf sein Icon gezogen wird. Aus Platzgründen stehen im Code keine
Kommentarzeilen. Wer etwas davon nicht versteht, darf sich ruhig bei mir melden.
---
on run
display dialog "Bitte den zu kopierenden Ordner
auf das Icon dieses Droplets ziehen." buttons "OK" default button 1 with icon 1
end run
on open itemList
set curdate to (current date)
copy curdate to tempDate
set month of tempDate to January
set dd to text -2 thru -1 of ("0" & (day of curdate))
set mm to text -2 thru -1 of ("0" & ((curdate - tempDate) div 2500000) + 1)
set yy to text -2 thru -1 of ("" & (year of curdate))
set actDate to (dd & "." & mm & "." & yy)
set okay to 0
repeat while okay = 0
set actDate to text returned of (display dialog "Das Datum für den Ordner ändern oder bestätigen:" default answer actDate)
try
set dd to (text 1 thru 2 of actDate)
set startDay to dd as integer
set mm to text 4 thru 5 of actDate
set im to mm as integer
set yy to text 7 thru 8 of actDate
set yyyy to ("20" & yy) as integer
set okay to 1
on error
display dialog "Dieses Datum ist ungültig.
Deine Eingabe: " & actDate & "
Neuer Versuch?" with icon 2
end try
if startDay < 0 or startDay > 31 then
set okay to 0
display dialog "Der Start-Tag ist unmöglich.
Deine Eingabe: " & actDate & "
Neuer Versuch?" with icon 2
end if
if im < 0 or im > 12 then
set okay to 0
display dialog "Diesen Monat gibt es nicht.
Deine Eingabe: " & actDate & "
Neuer Versuch?" with icon 2
end if
end repeat
set noGood to 0
set testVal to dd & mm & yy
if (count of testVal) is 6 then
repeat with i from 1 to 6
set curChar to character i of testVal
if curChar is not in "0123456789" then
set noGood to 1
exit repeat
end if
end repeat
end if
if noGood = 1 then
display dialog "Ungültiges Datum!
Deine Eingabe: " & actDate & "
Bitte Script neu starten." buttons "OK" default button 1 with icon 0
error number -128
end if
if yyyy mod 4 = 0 then
set dayLs to {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
else
set dayLs to {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
end if
set endDay to item im of dayLs
if endDay < startDay then
display dialog "Dieses Datum ist ungültig.
Deine Eingabe: " & actDate & "
Bitte Script neu starten." buttons "OK" default button 1 with icon 0
error number -128
end if
set AppleScript's text item delimiters to {":"}
repeat with anObject in itemList
set folderPath to anObject as string
if folderPath ends with ":" then
set containerPath to text items 1 thru -3 of folderPath
set oldName to text item -2 of folderPath
if (count of oldName) > 8 then
set restName to text 9 thru -1 of oldName
repeat with i from startDay to endDay
set newName to (text -2 thru -1 of ("0" & i)) & "." & mm & "." & yy & restName
try
tell application "Finder" to set newFolder to (duplicate folder folderPath)
tell application "Finder" to set name of newFolder to newName
end try
end repeat
end if
end if
end repeat
set AppleScript's text item delimiters to {":"}
end open
---
Das kompilierte Droplet ist unterwegs.
Hans Haesler <hsa@ringier.ch>
als Antwort auf: [#419039]