[GastForen Programmierung/Entwicklung AppleScript

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste

Datum und Zeit an Dateinamen anhängen

-Peter-
Beiträge gesamt: 7

12. Jun 2019, 09:07
Bewertung:

gelesen: 14637

Beitrag als Lesezeichen
Hallo, liebe Mit-Scripter

Habe mir dank verschiedener Quellen das folgende Script (Droplet) gebastelt. Es dient dazu, Dateinamen mit Erstellungsdatum und Zeit zu ergänzen.
Z.B.
FPRO4223 Kopie.JPG zu FPRO4223 Kopie___10.6.2019___10'50'24.JPG
FPRO4223 Kopie.RAF zu FPRO4223 Kopie___10.6.2019___10'50'24.JPG

Das Script:

Code
on open 
tell application "Finder"
set input to selection

repeat with x in input
set creationDate to creation date of x
set modDate to modification date of x

set fileInfo to (info for of file (item 1 of input as string)) --- scheint hier hängen zu bleiben
set {fileName, nExt} to {name of fileInfo, name extension of fileInfo}
if nExt is not missing value then
set origName to (text 1 thru -((count of nExt) + 2)) of fileName
end if

set cD to creation date of x
set the_year to year of (cD) as number
set the_month to month of (cD) as number
set the_day to day of (cD) as number
set ts to time string of cD
set c to offset of ":" in ts
set h to text -2 thru -1 of ("0" & (text 1 thru (c - 1) of ts))
set m to text (c + 1) thru (c + 2) of ts
set s to text (c + 4) thru (c + 5) of ts
set Zeit to (h & "'" & m & "'" & s)
set neuName to origName & "___" & ((the_day & "." & the_month & "." & the_year & "___" & Zeit) as string)
set name of x to neuName & "." & nExt
end repeat
end tell
end open



Es funktioniert wie gewünscht, wenn ich 1 Datei darauf ziehe. Schon bei der zweiten kommt die Fehlermeldung:

«class docf» "FPRO4223 Kopie.JPG" of «class cfol» "Desktop" of «class cfol» "mini" of «class cfol» "Users" of «class sdsk» of application "Finder" kann nicht in Typ string umgewandelt werden.

Code
error "«class docf» \"FPRO4223 Kopie.JPG\" of «class cfol» \"Desktop\" of «class cfol» \"mini\" of «class cfol» \"Users\"  
of «class sdsk» of application \"Finder\" kann nicht in Typ string umgewandelt werden." number -1700 from «class docf»
"FPRO4223 Kopie.JPG" of «class cfol» "Desktop" of «class cfol» "mini" of «class cfol» "Users" of «class sdsk» to string

Vielleicht kann mir jemand erklären, wo der Haken ist, worüber ich sehr froh wäre.

Dankbare Grüsse
Peter

(Dieser Beitrag wurde von Hans Haesler am 12. Jun 2019, 14:10 geändert)
Änderungsverlauf:
Beitrag geändert von Hans Haesler (Veteran) am 12. Jun 2019, 14:10