Here is my problem:
I have a simple find and replace script that opens a file located in /Volumes/Xserve HD/VARIABLEINPUTSHERE.package/testfile.pkg
It then open Text Wrangler does a find and replace for display name =Joe and Turns it into Display name = Bob
The problem here is that I keep getting file not found on my “theCommand” variable.
The True Path is /Volumes/Xserve HD/digital.package/testfile.pkg
When my dialog box opens up i type in digital so that it populate “theCommand” with the value digital thus it should give the path listed above.
When I take out the variable and put the file name directly in, it works fine.
Does any one have any suggestions?
property theCommand : ""
repeat while theCommand is ""
display dialog "Input File Name:" default answer theCommand
set theCommand to text returned of result
end repeat
tell application "TextWrangler"
open POSIX file "\"/Volumes/Xserve HD/" & theCommand & ".package/testfile.pkg\""
replace "displayName = \"BOB\"" using "displayName = \"JOE\"" searching in text of text document 1 options {starting at top:true}
close text document 1 saving yes
end tell
Browser: Firefox 7.0.1
Operating System: Mac OS X (10.7)
Are you sure you need quotes in the POSIX path string? I don’t have TextWrangler at the moment, so I can’t test it, but I have never seen paths put that way.
Try changing this line
open POSIX file "\"/Volumes/Xserve HD/" & theCommand & ".package/testfile.pkg\""
to
open POSIX file "/Volumes/Xserve HD/" & theCommand & ".package/testfile.pkg" as string
I’m not sure if you need the “as string” at the end, but it’s something I’ve got a habit of doing, maybe it’s just the peace of mind that it’s going to come out as a string no matter what…
set defaultLoc to alias "some_HFS_path"-- your packages folder here
set target to choose file default location defaultLoc with showing package contents
Saves you typing the package name (excluding interfering typo’s, too).