Find Jobs
Hire Freelancers

Applescript isDone() integration

€8-30 EUR

Suoritettu
Julkaistu yli 3 vuotta sitten

€8-30 EUR

Maksettu toimituksen yhteydessä
I have an Applescript who measure the phisical size of each pdf in the target folder an create a csv file. I need to add a check if the files are finished writing to disk before to start to measure each file. I founded this code who may help but I need someone to integrate it in my Applescript: (* isDone() Checks if a file has finished writing to disk. Parameters: File2Check: file path, alias, posix path LastFileSize: initialize with -1; seed each subsequent call with the return of the previous LastFileSize Returns: 2 item list: item 1 - true or false item 2 - the CurrentFileSize as integer++ (++ returns -1 if file does not exist) Examples: isDone("path:to:[login to view URL]", -1) --> {false, 6207} == file not done. isDone("path:to:[login to view URL]", 39402708) --> {false, -1} == file write aborted??? isDone("path:to:[login to view URL]", LastFileSize) --> {true, 564689207} == file is done. written by Jeff Case 2004 *) property StillGrowing : null property CurrentFileSize : null --property File2Check : "JData:Downloads:[login to view URL]" --property LastFileSize : -1 on run {File2Check, LastFileSize} tell application "Finder" if alias File2Check exists then else return {false, -1} end if end tell set File2Check to File2Check as Unicode text set StillOpen to isOpen(File2Check) isGrowing(File2Check, LastFileSize) if StillGrowing is false then return {true, CurrentFileSize} else return {false, CurrentFileSize} end if if StillOpen is false and StillGrowing is false then return {true, CurrentFileSize} else return {false, CurrentFileSize} end if end run on isOpen(File2Check) -- check the "open" status of the file -- thanks to captnswing for the 'lsof' command -- works on SMB transfers set ItzOpen to ((do shell script ("echo `lsof " & (quoted form of (POSIX path of (File2Check))) & " | wc -l`")) as integer) if ItzOpen = 0 then return false else return true end if end isOpen on isGrowing(File2Check, LastFileSize) -- parse the return of "ls" for the current file size - NOT the Finder -- sometimes it reports back as 0 even though some data has written -- so this waits for a valid "size" report from "ls" -- "ls" more responsive and reliable than a Finder query set CurrentFileSize to 0 repeat while CurrentFileSize is 0 set LSreturn to do shell script ("ls -l " & (quoted form of (POSIX path of alias (File2Check)))) set AppleScript's text item delimiters to " " set CurrentFileSize to (text item 4 of LSreturn) set AppleScript's text item delimiters to " " set CurrentFileSize to ((text item 1 of CurrentFileSize) as string) as integer set AppleScript's text item delimiters to "" end repeat set AppleScript's text item delimiters to "" if CurrentFileSize > LastFileSize then set StillGrowing to true else set StillGrowing to false end if end isGrowing
Projektin tunnus (ID): 27782073

Tietoa projektista

1 ehdotus
Etäprojekti
Aktiivinen 4 vuotta sitten

Haluatko ansaita rahaa?

Freelancerin tarjouskilpailun edut

Aseta budjettisi ja aikataulu
Saa maksu työstäsi
Kuvaile ehdotustasi
Rekisteröinti ja töihin tarjoaminen on ilmaista
Myönnetty käyttäjälle:
Käyttäjän avatar
❤️ Dear, How are you today? I have a rich experience in applescript. You can check my profile. Kindly provide me the details about the project. Looking forward from your end. Best regards
€50 EUR 7 päivässä
3,0 (3 arvostelua)
3,9
3,9

Tietoja asiakkaasta

Maan ITALY lippu
Ljubljana, Italy
5,0
4
Maksutapa vahvistettu
Liittynyt toukok. 2, 2016

Asiakkaan vahvistus

Kiitos! Olemme lähettäneet sinulle sähköpostitse linkin, jolla voit lunastaa ilmaisen krediittisi.
Jotain meni pieleen lähetettäessä sähköpostiasi. Yritä uudelleen.
Rekisteröitynyttä käyttäjää Ilmoitettua työtä yhteensä
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Ladataan esikatselua
Lupa myönnetty Geolocation.
Kirjautumisistuntosi on vanhentunut ja sinut on kirjattu ulos. Kirjaudu uudelleen sisään.