Hello all…
I am new to all of this but have picked up some books and followed tutorials etc, yet I still can’t find the reason for my error in this script. It seems like a reasonable thing…all I want to do is store off a folder path as a text variable that I can then write out to a file I just created. But whenever I try to run the script it errors out telling me it is unable to change this document file into a file (or into a class…depending upon how I try to do it). I know this is possible, and I know I must be doing this wrong, but I just don’t see the error. I know it must be messy newby scripting, but if anyone out there can help you would really be making my day
Here is the pertinent part of the script:
tell application "Finder"
activate
---define the folder path
set folderPath to (choose folder "Locate the folder")
set folderPathString to (folderPath) as alias
set folderPathText to folderPathString as text
set xFlag to 1 ---set flag if already exists
if (exists item "New Folder1" of folderPath) then
set xFlag to 2 ---make folder if it does not exist
end if
if xFlag is 1 then
make folder at (folderPath) with properties {name:"New Folder1"}
end if
if xFlag is 2 then
display dialog "New Folder1 already exists"
set rFlag to 1 --set flag if file exists
end if
if (exists item "Folderpathfile.txt") of folderPath then
set rFlag to 2 ---make file if it does not exist
end if
if rFlag is 1 then
make file at (folderPath) with properties {name:"Folderpathfile.txt", data:folderPathString}
end if
if rFlag is 2 then
display dialog "Folderpathfile.txt already exists"
end if
---write the path to the file for later use
set folderPathFile to ("Folderpathfile.txt") of (folderPath)
set folderContainer to container of folderPathFile
if rFlag is 1 then
open for access folderPathFile with write permission
end if
write folderPathText to RQpathFile of RQpathContainer
end tell
—ps…I want to be able to read out and use the path stored in the folderPathText file if the file does exist. I do this in place of writing to a preference file or such since my little app will reside on a firewire disk and be used with multiple systems in a testing script I am writing. So I don’t want to have to reset the path everytime it is run from a different system, but i do want to be able to change the path if the app is moved to a different disk…I hope that makes some sense…I was up pretty late trying to get this all to work