Can't make "path name" into type constant.

Hello all.

I’m pretty new to AppleScript and am attempting to create a script to backup networked drives.

I’m able to login to the account, select the folder/files to back up. The error comes when I get here:

set sourceFolder to the path to theStart

I get an AppleScript error stating “Can’t make 'username:folder” into type constant. It won’t run further.

If I use

set sourceFolder to the path of theStart

I get an error stating that "Can’t get path of ‘username:folder:’ ".

Is this something that is fixable, or am I stuck with my poorly-conceived Automator backup workflow?

Thanks for all the help-

-IA

Model: PowerBook G4
AppleScript: 1.10
Browser: Firefox 0.10.1
Operating System: Mac OS X (10.4)

“path to” works with the following:

What you need to do is run a scriptlet: choose folder. You then navigate to the folder you want and the script will return an alias with the path to the folder you chose. Copy that to your script: set Source_Folder to alias …

*Since your new you might request a script that does your goal outright. Then study it to see how it operates.

About paths in AS:

will only work if you have either
set theStart to “HardDiskName:Path:To:Folder:theStart” where each item between “:” is a folder name (Path: would be one of the folders in the path).
and then state it as
set sourceFolder to theStart
This is called a “hardwired” reference

OR

Set sourceFolder to (choose file) will bring up a promp and you can manually tell AS which folder.

If your using Automator and AS is new to you, again, you might simply request a script with well defined goals and parameters. Then you might end up with something really nice.
SC

theStart is defined through a Prompt already using the following:

display dialog "Do you want to back up a file or folder?
Choose Folder to back up ALL of your files." buttons {"File", "Folder", "Cancel"} default button "Folder"
if button returned of result = "File" then
	set theStart to (choose file with prompt "Select file(s):" with multiple selections allowed) as string
else if button returned of result = "Folder" then
	set theStart to (choose folder with prompt "Select a folder:") as string
end if

The result of this prompt should be passed into sourceFolder and used for the remainder of the backup process. The error seems to occur when attempting to get the path of the networked drive/folder to be backed up. It also occurs if I change the last line of above to

 "set theStart to the path of(choose folder with prompt "Select a folder:") as string"

What am I doing wrong?

Sitcom- I’d like to do this one myself as much as possible; it’s potentially being implemented into a school corporation environment and I want to be able to troubleshoot/update/comment my own work. Otherwise, I’de be more than happy to have someone else volunteer.

IA

-Respect :slight_smile:

OK then, “Debugging”…
“with multiple selections allowed” wouldn’t compile in my system, just checking that it does on yours? This may be because I’m on an older OS.

If you want to find out what’s going on, open your “Show result” window in the “Controls” menu option of Script Editor.

Open the display dialog handler in a new window:

*If you select mulitple files, you will have to process as such later, as theStart will be more than one processable item. Several files selected as theStart will not process correctly in a handler that is meant for theStart as a single item.

to find why your path isn’t processing, run the script and look at the values returned. You get proper returns for file and folder. Now that you have the reference, try to use it for something simple to see how AS handles it. Try opening it:

Here is the result of selecting a file as theStart:
“Disk:Applications:FileMaker Pro 5.5 Folder:Databases for Examples:Test1”

now, I try

and get an error

and get an error

still an error
one more option


tell application "Finder"
	open folder theStart
end tell

Here’s your quiz, what happens on the last one? So it seems your getting the correct return on the paths, but your not calling them with the correct ____________?
SC

So then, given that
“Disk:Applications:FileMaker Pro 5.5 Folder:Databases for Examples:Test1” IS theStart,

set sourceFolder to the path of theStart
is really achieved by
set sourceFolder to __________?

I wasn’t using the correct action, apparently. I’ve modified a few lines of code, and now everything works up to where I stopped scritping.

Thus far I can: Connect to a server using a unique username/password (with hidden password), Prompt user for files/folders to back up, copy those files from a remote server to the Desktop.

Last step is to either a) turn that folder into a disk image (compressed, preferrably) or burn it to a CD. Thanks all for the help.

IA

The lines

set theStart to (choose file with prompt “Select file(s):” with multiple selections allowed) as string

and [color=darkred]

set theStart to (choose folder with prompt “Select a folder:”) as string[/color]

coerce the alias returned by the choose file/choose folder command to a string; to get that reference back to a path, coerce it back to an alias:

set sourceFolder to (alias theStart)