Finder dialog stops script from running

I have a script that runs on a server, it automatically sorts files that are placed in a hot folder via a sharepoint. Only thing is when the Finder pops up any form of dialog box it stops the script running until the someone clicks OK. But no one knows the script has stopped until they check the server, is there a way of letting the script continue in the background if a dialog box appears?

A little more information will be helpful.

  1. What are the Finder messages?
  2. Can you post the script you are running?

It’s any message that the Finder pops up, if I don’t press OK everything stops working. This is the script:

And no I didn’t write it! :slight_smile:

(*
	WorkFlow Version 0.7.004
	
	-- 0.1		Initial Build
	-- 0.3		Added file monitor routine to bypass slow network transfers
	-- 0.5		Watched Folder version via Lingon - runs ever x minutes as set in the launchd job
	-- 0.7		Added support to trap for following errors:
					¢ invalid source files
					¢ improperly named files
					¢ failed pdf generation
					
						.004 - fixed log file handling
	
*)

global theWatchedFolder, ADresourceFolder, lowOptions, highOptions, lowOutputFol, highOutputFol, chainList, lowServerList, highServerList, printerList, failedFolder

-- TO DO
-- -- Add some error checking
-- -- -- particularly for .log files generated
-- -- Handle the original .ps file

on run
	-- Declare Paths to Resources
	set theWatchedFolder to "PDF:HotFolder"
	set ADresourceFolder to "PDF:Distiller Resources:"
	set lowOptions to ADresourceFolder & "joboptions:VC_low_res.joboptions"
	set highOptions to ADresourceFolder & "joboptions:VC_hi_res.joboptions"
	set lowOutputFol to ADresourceFolder & "lowHolding:"
	set highOutputFol to ADresourceFolder & "highHolding:"
	set failedFolder to "PDF:FailedJobs"
	set chainList to {"CURRY", "CURIR", "PCW", "PCWNR", "PCWIR", "DTPCW", "DT", "ADD", "EUR"}
	
	set lowServerList to {"Currys|CurrysDigital_LR_PDF:Weeks:", "Ireland_LR_PDF:Currys_Ireland:Weeks:", "PCWorld_LR_PDF:WEEKS:", "WNR_PCWorld_LR_PDF:Weeks:", "Ireland_LR_PDF:PCWorld_Ireland:Weeks:", "DTF_LR_PDF:WEEKS:", "DTF_LR_PDF:WEEKS:", "DTF_LR_PDF:WEEKS:", "DTF_LR_PDF:WEEKS:"}
	
	set highServerList to {"Currys|CurrysDigital_HR_PDF:Weeks:", "Ireland_HR_PDF:Currys_Ireland:Weeks:", "PCWorld_HR_PDF:WEEKS:", "WNR_PCWorld_HR_PDF:Weeks:", "Ireland_HR_PDF:PCWorld_Ireland:Weeks:", "DTF_HR_PDF:WEEKS:", "DTF_HR_PDF:WEEKS:", "DTF_HR_PDF:WEEKS:", "DTF_HR_PDF:WEEKS:"}
	
	set printerList to {"E-5000", "E-5000", "Toshiba", "E-5000", "E-5000", "E-5000", "E-5000", "E-5000", "E-5000"}
	
	-- Begin the workflow
	tell application "Finder"
		set theFiles to every file of folder theWatchedFolder
		repeat with i from 1 to (count theFiles)
			set aFile to item i of theFiles
			if (my _verifyFile(aFile, true)) then
				my _lowChain(aFile)
				my _highChain(aFile)
			end if
			move aFile to trash
		end repeat
	end tell
end run


-- Distiller handler to generate low/high res PDFs
to _Distill(aFile, outputPath, jobOptions)
	set aFilePosix to POSIX path of (aFile as Unicode text)
	tell application "Acrobat Distiller"
		set theResult to Distill sourcePath aFilePosix adobePDFSettingsPath (POSIX path of jobOptions) destinationPath (POSIX path of outputPath)
	end tell
	return theResult
end _Distill

-- Rename the PDF and store in proper location
to _storePrintFile(suffix)
	tell application "Finder"
		if suffix is "_LR" then
			set aPDF to item 1 of (get files of folder lowOutputFol) as alias
		else
			set aPDF to item 1 of (get files of folder highOutputFol) as alias
		end if
		my _verifyFile(aPDF, false)
		set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "_"}
		set {name:Nm, name extension:Ex} to (info for aPDF)
		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
		set name of aPDF to fileName
		try
			set {theGroup, na, wc} to text items of fileName
			set chain to text 3 thru -1 of wc
		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 AppleScript's text item delimiters to tid
		if Ex is equal to ".log" then
			move aPDF 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
						set theServer to POSIX path of (item i of lowServerList)
						exit repeat
					else
						set theServer to POSIX path of (item i of highServerList)
						tell application "Printer Setup Utility" to set current printer to printer (item i of printerList)
						tell application "Adobe Acrobat Pro"
							open aPDF
							print pages active doc PS Level 3 with binary output and shrink to fit
							close active doc
						end tell
						exit repeat
					end if
				end if
			end repeat
			set command to "/bin/mv -f " & (quoted form of (POSIX path of aPDF)) & space & (quoted form of theServer) & "Week" & (text 1 thru 2 of wc) & "/" & theGroup & "*/"
			do shell script command
			return true
		else
			move aPDF to folder failedFolder with replacing
			return false
		end if
	end tell
end _storePrintFile


-- Low Res Chain handler
to _lowChain(aFile)
	set lowResult to my _Distill(aFile, lowOutputFol, lowOptions)
	if lowResult is not 1 then
		--handle a error here on generation
		return false
	end if
	-- also need to verify not a .log file
	my _storePrintFile("_LR")
end _lowChain


-- High Res Chain handler
to _highChain(aFile)
	set highResult to my _Distill(aFile, highOutputFol, highOptions)
	if highResult is not 1 then
		--handle a error here on generation
		return false
	end if
	-- also need to verify not a .log file
	my _storePrintFile("_HR")
end _highChain


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

Just remembered I have it running as a User Agent using Lingon if that is relevant.