spirigwi •----->


Anmeldedatum: 10.07.2003 Beiträge: 1517 Wohnort: Olten-CH
|
Verfasst am: 07.10.2006 - 12:56 Titel: Finder-Objekt-Namen Suffix anhängen:Modification-DATUM+ZEIT |
|
|
Problem: Ein Finder-Objekt wie ZB File oder Ordner oder Image usw soll mehrmals im selben Ordner als Duplikat gespeichert werden können und damit neben dem Original einsehbar bleiben. Die von Apple generierten Zusätze an den Original-Namen(Kopie 1...) sind mir zu wenig informativ.
Idee mit AS:
• Ein Duplikat anlegen lassen Z.B von Hand mit [APFEL-æ]+D (oder ebenfalls mit einem AS).
• Dieses Produkt auf ein Drop-AS (dplt) (oder auf dessen Alias, welches ZB auf Schreibtisch liegt) "ziehen".
• Damit soll dem Dupplikat_Namen eine sinnvolle Zusatz-Bezeichnung angehängt werden, quasi als "Suffix".
Dabei soll der Original-Name weitgehend erhalten bleiben und das "Suffix" soll das Modifications-Datum/+ Zeit (= letzte Veränderung) beinhalten. Somit soll sich der neue Objekt-NAME gemäss seiner Datums- und zeitlichen Kriterien der Modification leicht einordnen lassen mit der Finder-Sortier-Obtion "nach Namen sortiert"
Beispiel hat Folgendes geschrieben: | HOST_SERVER.img..........................= Original Name
HOST_SERVER.img Kopie................= Name der durch Finder erzeugten Kopie
HOST_SERVER.img Kop-07.04.08T
HOST_SERVER.img Kop-07.04.09T..= Namen durch das "Namengeber-Droplet" erzeugt |
Datum Geber
ein als Droplet speicherbares AppleSkript hat Folgendes geschrieben: |
global DatTEX, d, HH, JJ, JJJJ, KalWoZA, MiMi, MM, MoName, TT, WoTgName, WoTgName2Its, WoTgName3Its, WoTgNameZA, MtName3Its, ss --DatTEXtER()
--=======================
property MaxLang : 31 - 1 - 9 - 5 --<--[OS9-max.Namenslänge 31]-Minus(1), -Datum(9), -Zeit (5)
--=======================
on run
--tell application "Finder" -- = "System Events"
--set FileListe to every file of (choose folder with prompt "Quellordner auswählen")
set FileListe to ¬
{file (choose file with prompt "Wähle ein file, um seinem Namen das Mod-Datum anzuhängen" as list)}
--{}<--EDIT am 22.11.06
--return FileListe
--end tell
my DatumGebER(FileListe)
end run
on open FileListe
my DatumGebER(FileListe)
end open
on DatumGebER(FileListe) --oooo
--error 0 & MaxLang
repeat with EinFile in FileListe
tell application "Finder"
set d to modification date of EinFile
end tell
--##########################
set DatTEX to (d) as string
my DatTEXtER() -- oooo
--##########################
set DatGeTEXtet to ¬
JJ & "." & MM & "." & TT & "T"
set ZeitGeTEXtet to HH & "h" & MiMi --=5
set DatName to DatGeTEXtet & ZeitGeTEXtet
tell application "Finder"
set NameUr to name of EinFile
if (length of NameUr > MaxLang) then -->20
set NameNeu to (text 1 thru (MaxLang) of NameUr)
else
set NameNeu to NameUr
end if
set NameNeu to NameNeu & "-" & DatName
set name of (contents of EinFile) to NameNeu
activate
end tell
end repeat
end DatumGebER
--ooooooooooooooUNIVERSAL-HANDLER oooo
on DatTEXtER() --ooooo
set AppleScript's text item delimiters to "" --falls in vorherigen Skripts umgestellt wurde
set a to DatTEX
set d to date a
set d to d -- + (1 * days)
date "Samstag, 3. September 2005 12:00:00 Uhr" --date-Tester: ZB date "1" dann ENTER
set Wort1 to word 1 of (d as text) --Donnerstag
set Wort2 to word 2 of (d as text) --8
set Wort3 to word 3 of (d as text) --September
set Wort4 to word 4 of (d as text) --2005
-- Wort5--Exkurs
set Wort5 to word 5 of (d as text) --0 OSX macht Fehler bei Rückwandlung
set Zeit to time of date DatTEX
set Stunde to round ((Zeit) / 3800) rounding down -->auf OSX falsch!
try
set Wort5 to word 5 of DatTEX
on error
set Wort5 to "00"
end try
--END -- Wort5--Exkurs
set Wort6 to word 6 of (d as text) --00
set Wort7 to word 7 of (d as text) --00
set Wort8 to word 8 of (d as text) --Uhr
--TAG##################
set TT to text -2 thru -1 of ("0" & d's day) --31.(ZB 31.Januar 05)
set WoTageListe to {"Montag", "Dienstag", "Mittwoch", "Donnerstag", ¬
"Freitag", "Samstag", "Sonntag"} --Montag =1
set WoTgName to word 1 of (d as text) --Dienstag
set WoTgName2Its to (text items 1 thru 2 of WoTgName) as text --Di
set WoTgName3Its to (text items 1 thru 3 of WoTgName) as text --Die
repeat with i from 1 to 7
if WoTgName = item i of WoTageListe then
set WoTgNameZA to text -2 thru -1 of ("0" & i) --Montag=1
exit repeat
end if
end repeat
--Woche################# 2 Donnerstage für Kalender-Wochenzahl
set DoDerWoDAT to (d - (WoTgNameZA * days)) + (4 * days)
set YearDoDerWoZA to DoDerWoDAT's year
set Tag4JanDesYearDoDerWoDAT to date ("4.1." & YearDoDerWoZA)
set WoTgName4JanDesYearDoDerWoDAT to word 1 of (Tag4JanDesYearDoDerWoDAT as text)
repeat with i from 1 to 7
if WoTgName4JanDesYearDoDerWoDAT = item i of WoTageListe then
set WoTgName4JanDesYearDoDerWoZA to text -2 thru -1 of ("0" & i) --Montag=1
exit repeat
end if
end repeat
set DoDesTag4JanDesYearDoDerWoDAT to ¬
(Tag4JanDesYearDoDerWoDAT - (WoTgName4JanDesYearDoDerWoZA * days)) + (4 * days)
set KalWoZA to (DoDerWoDAT - DoDesTag4JanDesYearDoDerWoDAT)
set KalWoZA to round ¬
(1.05 + ((DoDerWoDAT - DoDesTag4JanDesYearDoDerWoDAT) / (7 * 86400)) + (WoTgNameZA / 7)) ¬
rounding down
--Monat #################
set MonatsListe to {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", ¬
"August", "September", "Oktober", "November", "Dezember"}
set MoName to word 3 of (d as text)
repeat with i from 1 to 12
if MoName = item i of MonatsListe then
set MM to text -2 thru -1 of ("0" & i) --09
exit repeat
end if
end repeat
set MtName3Its to (text items 1 thru 3 of MoName) as text
--JJJJ #################
set JJJJ to ((year of d) as text) --2005
set JJ to (text items -2 thru -1 of JJJJ) as text --05
--Zeit #################
set HH to Wort5 -- word 5 of (DatTEX) --07 --geht nicht auf OSX!!
set MiMi to Wort6 --00
set ss to Wort7 --09
--0 erzeugen:
set HH to text -2 thru -1 of ("0" & HH)
set MiMi to text -2 thru -1 of ("0" & MiMi)
my MilleniumWandler1900Zu2000() --oooooooo
end DatTEXtER
on MilleniumWandler1900Zu2000() --oooooooo
if text item 1 of JJJJ = "1" then --<-1900
set JJJJ to "20" & (text -2 thru -1 of JJJJ)
end if
end MilleniumWandler1900Zu2000
|
EDIT= 22.11.06: nun läuft das AS OS9 (_X?) auch dann, wenn es noch nicht als droplet gespeichert ist. Für diese Version habe ich es allerdings auf das "choosen" von lediglich files reduziert. Die droplet-Version kann jedoch nebst files auch Ordner "umtaufen"
[EDIT= 14.4.07 ]
- Die Rolle der Uhrzeit als Namensteil des Finderobjektes habe ich für die Praxis unterschätzt und sie dem Snippet nun zugeführt,
- Die Berechnung der max. Namenslänge ist in property enthalten. _________________ Skript-Fan => ein � -Fan =>Scr¿¿-KongFuSius_Kurpfusius |
|