Applescript Pause einfügen, wenn Aktion davor noch nicht beendet

Tastentipper

Aktives Mitglied
Thread Starter
Dabei seit
26.02.2004
Beiträge
543
Reaktionspunkte
15
Hallo,

in einem Script werden Dateien an einen neuen Ort kopiert und anschließend umbenannt.
Bei kleinen Dateimengen läuft es super, wenn allerdings die Dateimenge groß ist und das Kopieren dauert, wird das Script mit einer Fehlermeldung beendet, dass die Schritte noch nicht ausgeführt werden können.

Kann man so eine Art Pause einfügen, die veranlasst, dass das Script erst weiter ausgeführt wird, wenn die Aktion davor beendet ist?
Wenn ja, müsste der Script teil aussehen?
 
Hallo,

wie kopierst Du die Dateien? Via Finder-Aufruf? Am elegantesten dürfte einfach cp via do shell script sein.
Das wartet dann von alleine bis es komplett albgenudelt ist.

Wenn Du es via Finder kopierst, dann könntest Du eine Endlosschleife machen, die das Skript immer ein paar Sekunde pausiert und die Dateigröße zum vorherigen Durchgang überprüft.
Gibt es keine Änderung mehr, dann wird es höchstwahrscheinlich fertig sein.

Schaue Dir auch mal considering application responses an:
https://developer.apple.com/library...gGuide/reference/ASLR_control_statements.html

Viele Grüße

Code:
--

repeat
  
    --
  
    set x to (info for anItemPath with size)
  
    --
  
    delay 3
  
    --
  
    set y to (info for anItemPath with size)
  
    --
  
    if x is equal to y then exit repeat
  
    --
  
end repeat

--
 
So sieht mein Script aus:




set
folderName1 to "PDF-Ansicht"
set folderName2 to "PDF-Proof"
set folderName3 to "PDF-Druck"
set folderName4a to "01"
set folderName4b to "02"
set folderName4c to "03"
set folderName4d to "04"
set folderName4e to "05"
set folderName4f to "06"
set folderName4g to "07"
set folderName4h to "08"
set folderName4i to "09"
set folderNameActive to name of front window of application "Finder"

tell application "Finder"
activate
activate front window
set anzahl1 to count of ((folders of window 1) as list)
if anzahl1 = 0 then
set anzahl2 to folderName4a
else if anzahl1 = 1 then
set anzahl2 to folderName4b
else if anzahl1 = 2 then
set anzahl2 to folderName4c
else if anzahl1 = 3 then
set anzahl2 to folderName4d
else if anzahl1 = 4 then
set anzahl2 to folderName4e
else if anzahl1 = 5 then
set anzahl2 to folderName4f
else if anzahl1 = 6 then
set anzahl2 to folderName4g
else if anzahl1 = 7 then
set anzahl2 to folderName4h
else if anzahl1 = 8 then
set anzahl2 to folderName4i
else if anzahl1 ≥ 9 then
set anzahl2 to anzahl1 + 1
end if

make new folder at front window with properties {name:anzahl2}
activate folder anzahl2 of front window
make new folder at folder anzahl2 of front window with properties {name:folderName1}
make new folder at folder anzahl2 of front window with properties {name:folderName2}
make new folder at folder anzahl2 of front window with properties {name:folderName3}

set anzahlNeu to count of ((folders of window 1) as list)
set folderName5 to anzahlNeu - 1
set folderName6 to anzahlNeu

if folderName5 = 1 then
set folderName5 to "01"
else if folderName5 = 2 then
set folderName5 to "02"
else if folderName5 = 3 then
set folderName5 to "03"
else if folderName5 = 4 then
set folderName5 to "04"
else if folderName5 = 5 then
set folderName5 to "05"
else if folderName5 = 6 then
set folderName5 to "06"
else if folderName5 = 7 then
set folderName5 to "07"
else if folderName5 = 8 then
set folderName5 to "08"
else if folderName5 = 9 then
set folderName5 to "09"
end if

copy every file of folder folderName5 of front window to folder folderName6 of front window
open folder folderName6 of front window
select every file of front window
close window folderNameActive
end tell

HIER MÜSSTE DIE PAUSE HIN, bevor es dann weiter geht


tell application "Finder"

-- großes V
set target_files1 to every file of front window whose name contains "_V"
repeat with current_file in target_files1
set new_filename1 to my getNewFileName1(name of current_file)
set name of current_file to new_filename1
end repeat


-- kleines v
set target_files2 to every file of front window whose name contains "_v"
repeat with current_file in target_files2
set new_filename2 to my getNewFileName2(name of current_file)
set name of current_file to new_filename2
end repeat
end
tell


on getNewFileName1(filename1)
set new_filename1 to do shell script "echo " & filename1 & " | perl -pe 's/_V(\\d+)/_V.++($a=$1)/e'"
return new_filename1
end getNewFileName1

on getNewFileName2(filename2)
set new_filename2 to do shell script "echo " & filename2 & " | perl -pe 's/_v(\\d+)/_v.++($a=$1)/e'"
return new_filename2
end getNewFileName2
 
So ich habe nun einfach ein

...
copy every file of folder folderName5 of front window to folder folderName6 of front window

try
open folder folderName6 of front window
on error

repeat until "Kopieren" is not in name of the windows
end repeat

try
open folder folderName6 of front window
end try
end try

...

einfügt. Damit bin ich am Ziel.
 
Zurück
Oben Unten