I discovered a technique for a particular program to be told to find a specific file at a certain location. The command is a simple line inside the program’s props (settings) file. For people installing the program for the first time a base props file is installed first which includes the mentioned command. For persons re-installing the program, these persons might already have a props file. Thus the idea of this script is to check whether they have a props file and if yes, to insert the command into the props file if it is not there already. The script also installs the file which the program’s props file will direct the program to. Although the script seems to work, BUT, either of two places seem to come up with an error.
Error at
set the name of file “HL.txt” of theDestinationFolder2 to “H.txt”
and
if exists file “limewire.props” of theDestinationFolder2 then
try …
error “Can’t get file "limewire.props" of alias "OSX:Users:me:Library:Preferences:LimeWire:".” number -1728 from file “limewire.props” of alias “OSX:Users:me:Library:Preferences:LimeWire:”
Since there’s multiple choice options, I have tried to limit my example to one of them so it does not look over-complicated. StefanK tried to guide me a little in a previous question but I was never able to get the project working. But since I found an alternative way of dealing with the issue which is simpler and more practical, I have had to rewrite the script accordingly.
I am still a basic learner of applescript.
set thisSourceP to path to resource "limewire.props"
set thisSource3 to path to resource "HL.txt"
set theDestinationFolder2 to (path to preferences folder from user domain)
set theDestinationFolder2 to ((theDestinationFolder2 as text) & "LimeWire:") as alias
if response is "X" then
try
do shell script "rm ~/Library/Preferences/LimeWire/H.txt" -- checks to see if they already had an earlier version of the H file installed and deletes if they did.
end try
tell application "Finder" to duplicate thisSource3 to theDestinationFolder2 with replacing --- copies the H file of choice X to the user's pref's folder
set the name of file "HL.txt" of theDestinationFolder2 to "H.txt" -- renames the file to the appropriate file-name. Multiple versions of this file so needed to have different names within the applescript installer.
if exists file "limewire.props" of theDestinationFolder2 then --- checks to see if the user already has a props file.
try . -- does a quoted text insertion into the limewire.props file
end try ... --- end of text insertion code if they already had a props file
else if not (exists file "limewire.props" of theDestinationFolder2) then -- if user does not have a props file then it duplicates the base one to their prefs folder.
try
duplicate thisSourceP to theDestinationFolder2
end try
end if
--- end of segment, then the alternative menu choice option code
end if