I’m have an application that I’m writing that I want to save some data to a file in the bundle. The code below seems to be working if the folder in the bundle does not exist, a new folder and data file are created. However if the folder exists I’m getting the following error "Finder got an error: The operation could not be completed because there is already an item with that name. I have a conditional statement which seems to work in a similar script using script editor which should stop the new folder from being created. Can someone see something that I don’t?
on will finish launching theObject
(* First Handler in load sequence *)
log "will finish launching"
set BundlePath to resource path of main bundle --set bundle path property
set ScriptLib to load script file (POSIX file (BundlePath & "/Scripts/Common_Functions.scpt")) -- load script for common handlers
tell application "Finder"
if not (exists POSIX file (BundlePath & "/userData")) then
make new folder at (POSIX file BundlePath) with properties {name:"userData"}
tell ScriptLib
set PresetList to buildPropertyString(baseUserPresets) --converts a record to text
writePresets(POSIX file (BundlePath & "/userData/userprestes"), PresetList) --writes the file
end tell
end if
end tell
end will finish launching