So the subroutine works fine when run as an independent script but when incorporated into the master script as direct code or subroutine it does not. Whats up?
delay 1
set i to 1
tell application "Finder"
if the (count of the items in folder "File Drop Box" in home) is greater than 0 then
set theFile to item i in folder "File Drop Box" in home
get the name extension of item i in folder "File Drop Box" in home
set theX to the result
set theName to the name of item i in folder "File Drop Box" in home as text
if theX is "xls" then
count theName
set theYear to items 1 through 2 of theName as text
set theQuarter to items 3 through 4 of theName as text
set theMonth to items 5 through 6 of theName as text
set theP to ("mspsi:Business:Finances:" & theYear & ":" & theQuarter & ":" & theMonth & ":") as text
set thePath to theP as alias
get home
exists item theName in thePath
set theVar to the result
if theVar is false then
move the first item in folder "File Drop Box" in home to thePath
else
open theFile
get the name of every process
set theXPath to (folder theMonth in folder theQuarter in folder theYear in folder "Finances" in folder "Business" in home)
set theDoc to (the first item in theXPath whose name is theName)
set theFN to theYear & theQuarter & theMonth as string
tell application "Numbers"
open theDoc
repeat
if document 2 exists then
exit repeat
end if
end repeat
set theRow to the value of the cells of the second row of the first table of the first sheet of document 1 as list
add row above the second row of the second column in first table of the first sheet of document 2
repeat with i from 1 to (count of theRow)
set the value of (cell i of the second row in first table of the first sheet of document 2) to (item i of theRow as string)
end repeat
close document 1 without saving
close document 1 with saving
delete theFile
end tell
end if
else if theX is "pdf" then
tell application "Automator"
open "mspsi:Programming:PDF MetaData.workflow:"
execute workflow "PDF Metadata"
set theR to result
set theResult to theR as list
set theXX to the first item in theResult as text
quit
end tell
run_item(theXX)
end if
else
exit repeat
end if
end tell
on run_item(theXX)
set thePath to ""
tell application "Finder"
set theFind to the entire contents of container "client" in home as list
set theList to the name of the entire contents of container "client" in home as list
set NX to the count theList
repeat with i from 1 to NX
set iI to item i of theList
if iI is equal to theXX then
set thePath to item i of theFind
exit repeat
end if
end repeat
end tell
return thePath
end run_item
automator simply pulls the metadata “keyword” from the PDF which is used to select the correct folder to move the item to. It is importing this path that I am stuck with. If there is an easier way to get this data then using Automator that would be very helpful as well.
Model: iMac
AppleScript: 2.1.2
Browser: Safari 533.18.5
Operating System: Mac OS X (10.6)