Simple Question

So, I just need to move a file from one location to the next. The only problem is that this will run on different machines where the home directory name can be, probably will be, different. I’ve gotten this to work on my machine, but I doubt it’ll work on everyones.
So how do I convert this “Macintosh HD:Users:apple:” into what is going to be standard on everyones machine?

e @ apple

set source to alias "Macintosh HD:Users:apple:Desktop:MOVE_ME.jpg"
set destination to "Macintosh HD:Users:apple:Desktop:Safari Script Menu"
tell application "Finder" to move source to destination

Does this help?

tell application "Finder"
	set home_path to home as text
	set source to alias (home_path & "Desktop:MOVE_ME.jpg")
	set destination to home_path & "Desktop:Safari Script Menu:"
	tell application "Finder" to move source to destination
end tell


oh yes. that works quite well. :slight_smile: thank you
i should have thought about it that way. I was thinking there’s some way to do it with “~” but I couldn’t for the life of me get it to work.

Thanks again!
e @ apple

That’s a command line thing.

Try something like this:

set sourceFile to ((path to desktop as Unicode text) & "MOVE_ME.jpg") as alias
set destinationFolder to ((path to desktop as Unicode text) & "Safari Script Menu:") as alias
tell application "Finder" to move source to destination

I guess part of my trouble is from a lack of understanding what exactly is include in the “Home Path”. This and not knowing the difference between using path names like “Macintosh HD:Users:apple:Library:Safari:” and ones like “/Users/apple/Library”
(in theory, those two paths are supposed to be the same…)
Enlighten me, please!

e @ apple

A colon-delimited pathname like “Macintosh HD:Users:apple:Library:Safari:” is called an HFS or a Mac path. Since Mac OS X (I do not think it was before then, but I have only been around since 10.3 myself), there is a parallel path namespace called POSIX. A slash-delimited pathname like “/Users/apple/Library/Safari/” is called a POSIX path. Some programming interfaces (AppleScript commands, shell-based programs, etc.) only take one type or the other, so sometimes you have to convert between them. You can convert from an HFS path to a POSIX path with POSIX path of HFSpath. Converting from POSIX to HFS can be done with POSIX file POSIXpath as Unicode text. There are also some other ways of specifying a path in AppleScript (alias, file specs) that change the conversion commands a bit, but those are the basics.

There are various ways of accessing the paths of various special places. The Finder application has some properties like startup disk, desktop, and home that can be used to access the named places. The value of these properties can usually only be used in Finder scripting since they are Finder-specific objects. But you can convert them to aliases, which are understood by many other applications and extensions to AppleScript. See the application entry of the Finder Basics section of the Finder dictionary for more information (File > Open Dictionary. in Script Editor).

The other major way of accessing the path to the special places is with the path to command in the StandardAdditions extension (since it is an extension no tell block is required, and it is usually best to only use it outside an application-targeted tell block). There are MANY options to path to, but a few that are similar to the Finder properties mentioned above are path to startup disk, path to desktop folder, and path to home folder. By default the return value from these commands is an alias, but if you want a string, you can add as Unicode text to the end. While this looks like an AppleScript coercion, it is really part of the path to command (you can also use as string or as text, but I avoid them because not all paths can be represented in pre-10.5 string or text objects which did not support the whole of Unicode). To get more detail on path to look at the path to entry in the File Commands section of the StandardAdditions dictionary.

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari 3.0.4 (523.12)
Operating System: Mac OS X (10.4)

Wow. Now thats the history, info and all that I was certainly missing. That was very VERY helpful and I’m sure I’ll be referring to this later.
Thank you all!

e @ apple