Find Jobs
Hire Freelancers

Applescript isDone() integration

€8-30 EUR

Complété
Publié il y a plus de 3 ans

€8-30 EUR

Payé lors de la livraison
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
N° de projet : 27782073

Concernant le projet

1 proposition
Projet à distance
Actif à il y a 4 ans

Cherchez-vous à gagner de l'argent ?

Avantages de faire une offre sur Freelancer

Fixez votre budget et vos délais
Soyez payé pour votre travail
Surlignez votre proposition
Il est gratuit de s'inscrire et de faire des offres sur des travaux
Décerné à :
Avatar de l'utilisateur
❤️ 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 en 7 jours
3,0 (3 commentaires)
3,9
3,9

À propos du client

Drapeau de ITALY
Ljubljana, Italy
5,0
4
Méthode de paiement vérifiée
Membre depuis mai 2, 2016

Vérification du client

Merci ! Nous vous avons envoyé un lien par e-mail afin de réclamer votre crédit gratuit.
Une erreur a eu lieu lors de l'envoi de votre e-mail. Veuillez réessayer.
Utilisateurs enregistrés Total des travaux publiés
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Chargement de l'aperçu
Permission donnée pour la géolocalisation.
Votre session de connexion a expiré et vous avez été déconnecté. Veuillez vous connecter à nouveau.