I'm doing an update to an desktop app I created awhile ago. The user writes to a sub-folder in the app bundle into a folder called Scoring Data. After installing the update, with the new bundle structure, there are two Scoring Data folders. one in the MacOS folder and another in the Resources/_MacOS/Scoring Data. The files which the user has created and that have been saved to the MacOS/Scoring Data folder are still there. What I'm trying to do with the code below is move the existing stacks from MacOS/Scoring Data to Resources/_MacOS/Scoring Data. Things seem to work until I get to the repeat.
Any help is appreciated.
Code: Select all
on MouseUP
if the platform = "MacOS" and the environment = "standalone application" then
put the defaultfolder into tOldDir
put StackPathMAC(the filename of this stack) & "MacOS/Scoring Data" into tFromPath
answer "tFromPath =" && tFromPath
put StackPath(the filename of this stack) into tToPath
answer "tToPath =" && tToPath
set the defaultfolder to tFromPath
put the files into tFileList
if tFileList is not empty then
answer tFileList -- this gives the correct list of stacks
repeat for each line nLine in tFileList
put line nLine of tFileList into tFileName
answer tFileName -- not getting to this
put url ("binfile:" & tFromPath & "/" & tFileName) into url ("binfile:" & tToPath & tFileName)
end repeat
set the defaultfolder to tOldDir
end if
end if
answer “Copy complete”
end MouseUP
--------------------------------
function StackPath pPath
set the itemDelimiter to slash
if the platform = "MacOS" and the environment = "standalone application" then
get the effective filename of stack pPath
put item 1 to -3 of it into pPath
put "/Resources/_MacOS" after pPath
return pPath & "/"
else
delete last item of pPath -- remove the last item to get the path to the containing folder
return pPath & "/"
end if
end StackPath
--------------------------------
function StackPathMAC pPathMAC -- only used for this situation
set the itemDelimiter to slash
get the effective filename of stack pPathMAC
put item 1 to -3 of it into pPathMAC
return pPathMAC & "/"
end StackPathMAC