Find Jobs
Hire Freelancers

Applescript isDone() integration

€8-30 EUR

Terminado
Publicado hace más de 3 años

€8-30 EUR

Pagado a la entrega
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
ID del proyecto: 27782073

Información sobre el proyecto

1 propuesta
Proyecto remoto
Activo hace 4 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
❤️ 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 días
3,0 (3 comentarios)
3,9
3,9

Sobre este cliente

Bandera de ITALY
Ljubljana, Italy
5,0
4
Forma de pago verificada
Miembro desde may 2, 2016

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.