I don't have the brainpower for your IF question, I think you mean:
true and true
which is the same as:
0 is 0 and 1 is 1
Hardcoded HFS paths are always a no-no, instead of "Macintosh HD" you say:
tell application "Finder" to startup disk as alias
which gives you a string you can append a string to.
Your home folder can be invoked like:
tell application "Finder" to path to home folder
You assemble a string like this:
tell application "Finder" to (path to home folder) & "Dropbox:Backup" as string
Note that the data class is still string. You can change it to alias by saying:
tell application "Finder" to ((path to home folder) & "Music") as string as alias
however this had to point to Music bacause I don't have "Dropbox". An alias invokes the existence of the location and you do it in Finder. Hope that helps.
That's because you didn't really use my code, you shortcutted. When you run an Applescript, you are running it in the Applescript interpreter. For example, say this:
This means "me" or "my" is the script's handler, so the result is a reference to the script:
So if you say:
Applescript's interpreter doesn't know what that means and it errors. But if you tell Finder to "home":
tell application "Finder" to home
Finder knows home is your home folder. What application you tell to interpret code is of the utmost importance. In the example you gave, Applescript knows what "path to home folder" means and assembles your string. This is why I told Finder to do it even though Applescript does it just as well, as a reminder that it is a Finder operation. So sending your string to Finder:
tell application "Finder" to exists file safariPlist
will get you "false", because no such file exists (on my computer).
A string is a data class of "string", you can see what class a variable is by saying:
class of safariPlist
Class "text" isn't a filepath, it is just some text. Class "alias" tells Applescript the string is a filepath. So if you say:
Applescript knows it is a filepath without even invoking Finder. Pretty cool, huh? This gets useful in long scripts involving various applications. So you can minimalistically say:
set safariPlist to (path to home folder) & "Library:Safari:Bookmarks.plist" as string as alias
if exists safariPlist then
display dialog "It exists."
tell application "Finder" to move safariPlist to trash
Note that in order to move a file to trash you need to invoke Finder because Applescript doesn't know what trash is. Hope that helps.