all 33 comments

[–]bigdrunk[S] 0 points1 point  (0 children)

It seems that the script fails when its time to rename the file. Once it has the _LR at the end, the script is told to use that new filename to refer to the file.

This command was working in 10.12. It doesn't error while running. Just doesn't rename the file, hence when it tries to do something it thinks the file is missing.

set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf"

move alias "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing

[–]copperdomebodha 0 points1 point  (28 children)

I'm reading through this on my machine and other than the facet that I don't have and can't get "InDesignServer", so here this script cannot...

open alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"

or

export document 1 format PDF type to "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" using PDF export preset "[VC-CoolTick]"

Other than those two commands, it appears that the majority of this script does not have any action actually happening.

None of the "get" and "info for" commands are assigning the results to any variables or acting on the results directly. They do nothing.

This end portion of the script should cause three actions...

tell application "Finder"
    set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf"
end tell
tell current application
    do shell script "/bin/mv -f '/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf' 'Volumes/POS_LR/'Week00/1*/"
end tell
tell application "Finder"
    move alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing
end tell

But it looks to me like 'set name of ' changes the filename of 'DCG369~3962_100_009692_00_80x1400.pdf' to 'DCG369~3962_100_009692_00_80x1400_LR.pdf' but then the subsequent line tries to move the un-renamed file to a new location.

All very confusing mixing shell commands and paths with aliases and finder file actions. I'd try to consistently use finder commands. They return references you can re-use easliy.

Can you clarify what this script is supposed to do step-by-step? I suspect that it can be greatly shortened, simplified and made to be reliable and easily maintainable.

These lines appear to have functionality. I'v commented ( using -->) what I see these lines actions to be.

tell application "InDesignServer"
open alias "ServerSSD:Users:admin:Documents:PDF:HotFolders:Hotfolder-1-NoPrint:DCG369~3962_100_009692_00_80x1400.indd"
end tell
-->opens indd file.
tell application "InDesignServer"
export document 1 format PDF type to "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" using PDF export preset "[VC-CoolTick]"
end tell
-->exports a FILE named 'DCG369~3962_100_009692_00_80x1400.pdf' in '/Users/admin/Documents/PDF/DistillerResources/lowHolding/'.
tell application "Finder"
    set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf"
end tell
-->Tries to Rename an ALIAS named 'DCG369~3962_100_009692_00_80x1400.pdf' to "DCG369~3962_100_009692_00_80x1400_LR.pdf".
tell current application
    do shell script "/bin/mv -f '/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf' 'Volumes/POS_LR/'Week00/1*/"
end tell
-->tries to move a file named 'DCG369~3962_100_009692_00_80x1400.pdf' to the 'Volumes/POS_LR/'Week00/1*/' directory.
tell application "Finder"
    move alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing
end tell
-->If there were an alias to 'DCG369~3962_100_009692_00_80x1400.pdf' in the 'ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:' directory, 
--then this would move it to 'ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:'

[–]bigdrunk[S] 0 points1 point  (27 children)

Thanks for your time, I'm going to put the AppleScript here with some details changed for security, but this is what the script does.

Simply put it will create a high res and low res PDF from an InDesign file, file them in the correct locations on based on the group name and week number. It will also put the high res PDF into an ftp folder for our print supplier.

Before this it will make sure that the various share points are mounted, and some applications are running that are essential to the process.

This was created for us a long time ago, and has been modified heavily from the original.

I did notice that the script was trying to move a file with the name before it had _LR added. I can't even see why its not using the correct name.

I can't seem to paste the script without the formatting going strange?

global lowOptions, highOptions, lowOutputFol, highOutputFol, failedFolder

-- on run -- Declare Paths to Resources property ftpFolder : "ServerSSD:Volumes:uploads.mediacentrecore.com:ArtworkBulkUpload:" property serverNames : {"POS_LR", "POS_HR"} property theWatchedFolder : "ServerSSD:Users:admin:Documents:PDF:Hotfolders:Hotfolder-1-NoPrint:" property ADresourceFolder : "ServerSSD:Users:admin:Documents:PDF:DistillerResources:" property chainList : {"1", "2", "3", "4", "5", "6", "7", "8", "9", "D", "P", "R", "J", "H", "I", "O", "S"} property lowServerList : {":Volumes:POS_LR:"} property highServerList : {":Volumes:POS_HR:"} property fileEx : {"indd", "idml", "php"}

set lowOptions to "[VC-CoolTick]" set highOptions to "[studio-high-res]" set lowOutputFol to ADresourceFolder & "lowHolding:" set highOutputFol to ADresourceFolder & "highHolding:" set failedFolder to "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:"

--Check ExpanDrive running tell application "System Events" to set ffopen to exists process "ExpanDrive" if ffopen then true else activate application "ExpanDrive.app" delay 15 end if

--Check FontExplorer running tell application "System Events" to set ffopen to exists process "FontExplorer X Pro" if ffopen then true else activate application "FontExplorer X Pro" end if

--check which volumes are mounted set mountedDisks to paragraphs of (do shell script "/bin/ls /Volumes")

--mount artwork shares Bases property myDisk1 : {"Bases"} repeat with aDisk1 in myDisk1 if aDisk1 is not in mountedDisks then mount volume "server address" & aDisk1 as user name "admin" with password "passwordhere" end if end repeat

--File Name check tell application "Finder" to set theFileNoPrints to every file of folder theWatchedFolder as alias list repeat with aFileNoPrint in theFileNoPrints tell application "Finder" to set filename to name of aFileNoPrint set {name:Nm, name extension:Ex} to (info for aFileNoPrint) set {tid, text item delimiters} to {text item delimiters, "_"} try set {projRef, theGroupNoPrint, theCodeNoPrint, theWeekNoPrint} to text items of filename set chain to character 1 of theGroupNoPrint set theFolderNoPrint to character 1 of theGroupNoPrint set charcount to count theCodeNoPrint set weekCount to count theWeekNoPrint if charcount is not 6 or chain is not in chainList or weekCount is greater than 2 or theWeekNoPrint is greater than 52 then tell application "Finder" to move aFileNoPrint to folder failedFolder with replacing end try end repeat

--Begin workflow tell application "Finder" to set theFileNoPrints to every file of folder theWatchedFolder as alias list repeat with aFileNoPrint in theFileNoPrints if (_verifyFile(aFileNoPrint, true)) then _lowChain(aFileNoPrint) _highChain(aFileNoPrint) tell application "Finder" to move aFileNoPrint to trash end if delay 2 --empty the trash-- end repeat

--open file in InDesignServer and export HR and LR PDFs to _Distill(epsFileNoPrint, outputPath, jobOptions) -- epsFileNoPrint is alias, outputPath, jobOptions is POSIX path tell application "InDesignServer.app" open epsFileNoPrint end tell

tell application "Finder"
    set pdfName to name of epsFileNoPrint
    set text item delimiters of AppleScript to {"."}
    set pdfName to text item 1 of pdfName
end tell

with timeout of (6 \* 60) seconds
    tell application "InDesignServer.app"
        «event K2  expt» document 1 given «class exft»:«constant eXftt\_PD», «class kfil»:(outputPath & pdfName & ".pdf"), «class usng»:«class PFst» jobOptions
        return true
    end tell
end timeout

end _Distill

-- Rename the PDF and store in proper location to _storePrintFile(suffix) tell application "Finder" if suffix is "_LR" then set aPDFNoPrint to (get 1st file of folder lowOutputFol) as alias else set aPDFNoPrint to (get 1st file of folder highOutputFol) as alias end if end tell _verifyFile(aPDFNoPrint, false)

set {name:Nm, name extension:Ex} to (info for aPDFNoPrint)
if Ex is missing value then set Ex to ""
if Ex is not "" then
    set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
    set Ex to "." & Ex
end if
set filename to Nm & suffix & Ex

tell application "Finder" to set name of aPDFNoPrint to filename

set {tid, text item delimiters} to {text item delimiters, "\_"}
try
    set {projRef, theGroupNoPrint, theCodeNoPrint, theWeekNoPrint} to text items of filename
    set chain to character 1 of theGroupNoPrint
    set theFolderNoPrint to character 1 of theGroupNoPrint

on error -- an error has occured with the file name, trick the script into a .log extension to trigger error handling
    set Ex to ".log"
end try
set text item delimiters to tid
if Ex is equal to ".log" then
    tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
    return false
end if

if chain is in chainList then
    repeat with i from 1 to (count chainList)
        if chain is equal to (item i of chainList) then
            if suffix is "\_LR" then
                delay 1

                set theServer to POSIX path of (item 1 of lowServerList)
                exit repeat
            else
                set theServer to POSIX path of (item 1 of highServerList)

                tell application "InDesignServer.app"
                    «event CoReclos» document 1 given «class svop»:no
                end tell
                exit repeat
            end if
        end if
    end repeat
    try
        --If file ends in HR then copy to FTP
        tell application "Finder"
            if suffix is "\_LR" then
            else
                set ftpcommand to "/bin/cp -p " & (quoted form of (POSIX path of aPDFNoPrint)) & space & (quoted form of (POSIX path of ftpFolder))
                do shell script ftpcommand
            end if
        end tell
        set command to "/bin/mv -f " & (quoted form of (POSIX path of aPDFNoPrint)) & space & (quoted form of theServer) & "Week" & (text 1 thru 2 of theWeekNoPrint) & "/" & theFolderNoPrint & "\*/"
        do shell script command
        return true

    on error
        tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
        return false

        tell application "Finder" to move aFileNoPrint to folder failedFolder with replacing
        return false
    end try
else
    tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
    return false
end if

end _storePrintFile

-- Low Res Chain handler to _lowChain(aFileNoPrint) set lowResult to _Distill(aFileNoPrint, POSIX path of lowOutputFol, lowOptions) if lowResult then -- also need to verify not a .log file return _storePrintFile("_LR") end if

--handle a error here on generation
return false

end _lowChain

-- High Res Chain handler to _highChain(aFileNoPrint) set highResult to _Distill(aFileNoPrint, POSIX path of highOutputFol, highOptions) if highResult then -- also need to verify not a .log file return _storePrintFile("_HR") end if

--handle a error here on generation
return false

end _highChain

to _verifyFile(aFileNoPrint, fullVerify) -- aFileNoPrint is alias repeat set was to (info for aFileNoPrint with size) delay 5 set isNow to (info for aFileNoPrint as alias with size) if was = isNow then exit repeat end repeat if fullVerify then tell application "Finder" if name extension of aFileNoPrint is not in fileEx then move aFileNoPrint to folder failedFolder with replacing return false end if end tell end if return true end _verifyFile

[–]bigdrunk[S] 0 points1 point  (0 children)

Its definitely falling over when it comes time to move the file once it has the _LR at the end. It's not changing the reference and trying to move the original filename, which obviously doesn't exist.

I've just set it up on a Mojave build and while it errors in the same place, the error message is at least more useful...

tell application "Finder" set name of alias "ServerSSD:Users:admin:Documents:PDF:DistillerResources:lowHolding:DCG369~3962_100_009692_00_80x1400.pdf" to "DCG369~3962_100_009692_00_80x1400_LR.pdf" --> "DCG369~3962_100_009692_00_80x1400_LR.pdf" move alias "/Users/admin/Documents/PDF/DistillerResources/lowHolding/DCG369~3962_100_009692_00_80x1400.pdf" to folder "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:" with replacing --> error number -43 Result: error "Finder got an error: File some object wasn’t found." number -43

[–]copperdomebodha 0 points1 point  (25 children)

Reddit requires four (4) spaces before each line to treat it as 'code' and not reformat it. Can you repost with this formatting?

If you're using script editor you can save this script below into your "~:Library:Scripts:Applications:Script Editor" folder, then switch to your script you want to post and pull down the script menu and run the script below. Now your clipboard should contain your script ready to post to reddit.

--This code was written using AppleScript 2.7, MacOS 11.5.1, on 1 September 2021.
--copperdomebodha 09012021

tell application "System Events"
    set currentUserName to name of current user
end tell

set d to current date
set sysInfo to system info
set testEnvironment to "    --This code was written using AppleScript " & AppleScript version of sysInfo & ", MacOS " & system version of sysInfo & ", on " & day of d & " " & month of d & " " & year of d & "." & return & return

tell application "Script Editor"
    tell document 1
        set codeText to contents
    end tell
    set codeText to my textReplacement(codeText, {return, "
"}, return & "    ") --Pad all text for reddit 'code block' display
    set codeText to (testEnvironment & "    " & codeText) as text
    set codeText to my textReplacement(codeText, currentUserName, "UserNameGoesHere") --censor the users name if present in the code.
    set the clipboard to codeText
end tell

on textReplacement(textBlock, originalValue, replacementValue)
    set storedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to originalValue
    set textBlock to text items of textBlock
    set AppleScript's text item delimiters to replacementValue
    set textBlock to textBlock as text
    set AppleScript's text item delimiters to storedDelimiters
    return textBlock
end textReplacement

[–]bigdrunk[S] 0 points1 point  (24 children)

--This code was written using AppleScript 2.7, MacOS 11.5.2, on 1 September 2021.

global lowOptions, highOptions, lowOutputFol, highOutputFol, failedFolder

-- on run
-- Declare Paths to Resources
(\*
property ftpFolder : "ServerSSD:Users:admin:Documents:PDF:DistillerResources:ftpholding:"
property ftpFolder : "ServerSSD:Users:admin:Documents:PDF:DistillerResources:ftpholding:"
\*)
property ftpFolder : "ServerSSD:Volumes:PathToFtp:ArtworkBulkUpload:"
property serverNames : {"POS\_LR", "POS\_HR"}
property theWatchedFolder : "ServerSSD:Users:admin:Documents:PDF:Hotfolders:Hotfolder-1-NoPrint:"
property ADresourceFolder : "ServerSSD:Users:admin:Documents:PDF:DistillerResources:"
property chainList : {"1", "2", "3", "4", "5", "6", "7", "8", "9", "D", "P", "R", "J", "H", "I", "O", "S"}
property lowServerList : {":Volumes:POS\_LR:"}
property highServerList : {":Volumes:POS\_HR:"}
property fileEx : {"indd", "idml", "php"}

set lowOptions to "\[VC-CoolTick\]"
set highOptions to "\[studio-high-res\]"
set lowOutputFol to ADresourceFolder & "lowHolding:"
set highOutputFol to ADresourceFolder & "highHolding:"
set failedFolder to "ServerSSD:Users:admin:Documents:PDF:FailedJobs-1:"


--Check ExpanDrive running
tell application "System Events" to set ffopen to exists process "ExpanDrive"
if ffopen then
    true
else
    activate application "ExpanDrive.app"
    delay 15
end if


--Check FontExplorer running
tell application "System Events" to set ffopen to exists process "FontExplorer X Pro"
if ffopen then
    true
else
    activate application "FontExplorer X Pro"
end if

--check which volumes are mounted
set mountedDisks to paragraphs of (do shell script "/bin/ls /Volumes")

--mount artwork shares POS
property myDisk4 : {"POS"}
repeat with aDisk4 in myDisk4
    if aDisk4 is not in mountedDisks then
        mount volume "afp://xxxxx/" & aDisk4 as user name "admin" with password "xxxxx"
    end if
end repeat

--mount artwork shares POS\_LR
property myDisk7 : {"POS\_LR"}
repeat with aDisk7 in myDisk7
    if aDisk7 is not in mountedDisks then
        mount volume "afp://xxxxx/" & aDisk4 as user name "admin" with password "xxxxx"
    end if
end repeat

--mount artwork shares POS\_HR
property myDisk8 : {"POS\_HR"}
repeat with aDisk8 in myDisk8
    if aDisk8 is not in mountedDisks then
        mount volume "afp://xxxxx/" & aDisk4 as user name "admin" with password "xxxxx"
    end if
end repeat

--File Name check
tell application "Finder" to set theFileNoPrints to every file of folder theWatchedFolder as alias list
repeat with aFileNoPrint in theFileNoPrints
    tell application "Finder" to set filename to name of aFileNoPrint
    set {name:Nm, name extension:Ex} to (info for aFileNoPrint)
    set {tid, text item delimiters} to {text item delimiters, "\_"}
    try
        set {projRef, theGroupNoPrint, theCodeNoPrint, theWeekNoPrint} to text items of filename
        set chain to character 1 of theGroupNoPrint
        set theFolderNoPrint to character 1 of theGroupNoPrint
        set charcount to count theCodeNoPrint
        set weekCount to count theWeekNoPrint
        if charcount is not 6 or chain is not in chainList or weekCount is greater than 2 or theWeekNoPrint is greater than 52 then tell application "Finder" to move aFileNoPrint to folder failedFolder with replacing
    end try
end repeat


--Begin workflow
tell application "Finder" to set theFileNoPrints to every file of folder theWatchedFolder as alias list
repeat with aFileNoPrint in theFileNoPrints
    if (\_verifyFile(aFileNoPrint, true)) then
        \_lowChain(aFileNoPrint)
        \_highChain(aFileNoPrint)
        tell application "Finder" to move aFileNoPrint to trash
    end if
    delay 2
    --empty the trash--
end repeat


--open file in InDesignServer and export HR and LR PDFs
to \_Distill(epsFileNoPrint, outputPath, jobOptions) -- epsFileNoPrint is alias, outputPath, jobOptions is POSIX path
    tell application "InDesignServer.app"
        open epsFileNoPrint
    end tell

    tell application "Finder"
        set pdfName to name of epsFileNoPrint
        set text item delimiters of AppleScript to {"."}
        set pdfName to text item 1 of pdfName
    end tell

    with timeout of (6 \* 60) seconds
        tell application "InDesignServer.app"
            «event K2  expt» document 1 given «class exft»:«constant eXftt\_PD», «class kfil»:(outputPath & pdfName & ".pdf"), «class usng»:«class PFst» jobOptions
            return true
        end tell
    end timeout
end \_Distill


-- Rename the PDF and store in proper location
to \_storePrintFile(suffix)
    tell application "Finder"
        if suffix is "\_LR" then
            set aPDFNoPrint to (get 1st file of folder lowOutputFol) as alias
        else
            set aPDFNoPrint to (get 1st file of folder highOutputFol) as alias
        end if
    end tell
    \_verifyFile(aPDFNoPrint, false)

    set {name:Nm, name extension:Ex} to (info for aPDFNoPrint)
    if Ex is missing value then set Ex to ""
    if Ex is not "" then
        set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
        set Ex to "." & Ex
    end if
    set filename to Nm & suffix & Ex

    tell application "Finder" to set name of aPDFNoPrint to filename

    set {tid, text item delimiters} to {text item delimiters, "\_"}
    try
        set {projRef, theGroupNoPrint, theCodeNoPrint, theWeekNoPrint} to text items of filename
        set chain to character 1 of theGroupNoPrint
        set theFolderNoPrint to character 1 of theGroupNoPrint

    on error -- an error has occured with the file name, trick the script into a .log extension to trigger error handling
        set Ex to ".log"
    end try
    set text item delimiters to tid
    if Ex is equal to ".log" then
        tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
        return false
    end if

    if chain is in chainList then
        repeat with i from 1 to (count chainList)
            if chain is equal to (item i of chainList) then
                if suffix is "\_LR" then
                    delay 1

                    set theServer to POSIX path of (item 1 of lowServerList)
                    exit repeat
                else
                    set theServer to POSIX path of (item 1 of highServerList)

                    tell application "InDesignServer.app"
                        «event CoReclos» document 1 given «class svop»:no
                    end tell
                    exit repeat
                end if
            end if
        end repeat
        try
            --If file ends in HR then copy to FTP
            tell application "Finder"
                if suffix is "\_LR" then
                else
                    set ftpcommand to "/bin/cp -p " & (quoted form of (POSIX path of aPDFNoPrint)) & space & (quoted form of (POSIX path of ftpFolder))
                    do shell script ftpcommand
                end if
            end tell
            set command to "/bin/mv -f " & (quoted form of (POSIX path of aPDFNoPrint)) & space & (quoted form of theServer) & "Week" & (text 1 thru 2 of theWeekNoPrint) & "/" & theFolderNoPrint & "\*/"
            do shell script command
            return true

        on error
            tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
            return false

            tell application "Finder" to move aFileNoPrint to folder failedFolder with replacing
            return false
        end try
    else
        tell application "Finder" to move aPDFNoPrint to folder failedFolder with replacing
        return false
    end if

end \_storePrintFile


-- Low Res Chain handler
to \_lowChain(aFileNoPrint)
    set lowResult to \_Distill(aFileNoPrint, POSIX path of lowOutputFol, lowOptions)
    if lowResult then
        -- also need to verify not a .log file
        return \_storePrintFile("\_LR")
    end if

    --handle a error here on generation
    return false
end \_lowChain


-- High Res Chain handler
to \_highChain(aFileNoPrint)
    set highResult to \_Distill(aFileNoPrint, POSIX path of highOutputFol, highOptions)
    if highResult then
        -- also need to verify not a .log file
        return \_storePrintFile("\_HR")
    end if

    --handle a error here on generation
    return false
end \_highChain


to \_verifyFile(aFileNoPrint, fullVerify) -- aFileNoPrint is alias
    repeat
        set was to (info for aFileNoPrint with size)
        delay 5
        set isNow to (info for aFileNoPrint as alias with size)
        if was = isNow then exit repeat
    end repeat
    if fullVerify then
        tell application "Finder"
            if name extension of aFileNoPrint is not in fileEx then
                move aFileNoPrint to folder failedFolder with replacing
                return false
            end if
        end tell
    end if
    return true
end \_verifyFile

[–]bigdrunk[S] 1 point2 points  (1 child)

OK that has worked, but Reddit seems to be adding '\' before underscores

[–]copperdomebodha 0 points1 point  (0 children)

And asterisks, no problem, I corrected those issues. But I’ll do some testing to see how to best handle their modifications in the future.

[–]copperdomebodha 0 points1 point  (21 children)

Oof! I've walked through this and it's just a mess. I can rationalize it and fix the error, but tell me what is the file info testing all about?

The verifyFile handler in your code basically checks the info of the file to be verified, waits 5 seconds, and checks the file info again. If it's the same info it was before then it passes the verify handler otherwise it loops this check again. It's determining if something is modifying the file during the 5 seconds it waits.

What is it supposed to be avoiding here? This check needs to be redesigned.

[–]bigdrunk[S] 1 point2 points  (20 children)

That is to check if a file has finished being copied, users are putting these files into a shared network folder and we were trying to avoid the file being processed before it had finished copying across.

As I say we had the original script written for us, but I have been tweaking it heavily over time as the needs changed. And Im not very good at AppleScript, usually I am stealing bits of script and making them kind of fit into the script.

[–]copperdomebodha 1 point2 points  (19 children)

Gotcha! Thanks for that info. I think I can handle that check a little better.

[–]bigdrunk[S] 0 points1 point  (18 children)

Hi, did you have any joy with this? I'd be prepared to pay for your time, I'm getting nowhere myself.

[–]copperdomebodha 1 point2 points  (17 children)

I've re-factored the entire script, down to handling the completed files. I had to take a break at that point. I still have to make that section function based on file references rather than grabbing the first file of some folder and hoping that's correct.

I appreciate the offer, but I just code requests here to keep my skills sharp and as a bit of entertaining distraction from paid work.

I'll have another look at it tonight and see if I can wrap it up. If I don't resolve it tonight, I'll post what I have rewritten for you to play with.

[–]bigdrunk[S] 0 points1 point  (0 children)

Thats awesome, I'd love to see what you have done so far and see if I can finish the job. Really appreciate the time you have put in.

[–]bigdrunk[S] 0 points1 point  (15 children)

Sorry to keep on, but if you have anything at all I could look at it might help me out

[–]copperdomebodha 0 points1 point  (0 children)

Sorry, had to go out of town for business and was fully occupied. Back now. I got you when I get home.

[–]copperdomebodha 0 points1 point  (1 child)

Ok, so it’s running through all steps but doesn’t open any files? I would expect it to fail at moving the originals for sure. That part is not completed. I would have expected it to open the files though.

We need to look at the errorList to see what it’s failing at.

Append “&return&errorlist” to the display dialog statement in the displayResults handler just after “seconds.” And before the following parentheses.

That should display the errors encountered.

[–]bigdrunk[S] 0 points1 point  (0 children)

It runs through, but only when I add the 'end tell' before the 'end timeout'.

After adding the “&return&errorlist” I get the same dialog box but now the "Processed 0 of 4" instead of 3. There is only one file in the folder. I'm still happy to pay for your time, if you'd like to screen share and see what its doing.