Dynamic script

Hi,

I am a newbie to AppleScript but it looks very promising, the first application that I have for it is a little script that would dynamically build aliases of files depending on the user’s selection. So far I was able to make a script that will make aliases of files, but i have to “hard code” the “original” file and the destination of the alias. Would it be possible to tell AppleScript to parse a text file with that information and more importantly to build the script dynamically (not having to use AppleScript studio or AppleScript Editor to compile the script).
Thank you very much in advance for any input about this.

Ben

Hi, Ben;

When you use “set myFile to (choose file)” the result in the variable myFile (or whatever) is an alias to the file chosen from a standard Finder dialog box.

With respect to extracting file names from a document, aliases to those can only be found if the file exists. Are you saying that given a document with file names you want to find them and create aliases to them in your script?

We need more info to be specific about this.

Hi binouch,

Here’s a modified version of the script I use to make aliai.


property folder_ref : missing value
--
tell application "Finder"
	set the_sel to selection
end tell
if the_sel is {} then
	display dialog "Nothing was selected." giving up after 5
	return
end if
tell application "Finder"
	if not (exists folder_ref) then
		set folder_ref to (choose folder with prompt ¬
			"Choose a folder for the alias:") -- or make a new one
	end if
end tell
tell application "Finder"
	make alias file at folder_ref to the_sel
end tell
display dialog "The alias' have been created." giving up after 5

It stores the destination folder in the script property.

Edited: come to think of it, this won’t work if run as a compiled script from the script menu. If would work only if run as an application from the Dock. You WOULD need some other way to store the info.

gl,

Ok maybe i was a little too general about what i want to do, so here are more details. In the network environment in which i work users get files from a large file system that they mount on their mac. Since the files they pull from there are rather big (graphic files up to 2GB) we try to save space and alias those files when they are reused for example. The reason why we need real Mac aliases and not unix “ln” for example is that Adobe Illustrator or other software won’t know how to use those symbolic links. In the system I’m trying to implement users browse to the files they need to reuse using a web browser and add them to a “selection basket” once their selection is done i would like them to be able to click on something that would let them download an AppleScript that would have the info about the original file and the destination of where the aliases of those files should go, and run that script so that they don’t have to go manually make the aliases.
So i was thinking of doing it in 2 ways 1. (my preference) is that everything is contained in a dynamically built AppleScript file that they can double click on and it will do the work or 2. Make a small program that will require a text file to be chosen (text file would be dynamically built) and it would have the info in there as to where and from where to make the aliases.
Does all this make sense to you guys?

Thank you very much for your help.

Ben

Sounds feasible. What does the content of the “Selection Basket” look like? Is it to be a simple text file? Is it just the names of the files chosen or will it include path information? Is there only one such server?

If the server is mounted on the user’s desktop, does holding down command-option while dragging the file to their desktop produce an alias to the file on their desktop?

Hi Adam,

The files in the selection basket can be the full path of the file (path+file name) and the aliases shouldn’t be built on the desktop but rather in the destination directory on the server where the new work is going to be saved. And yes there are more than one “volume” that’s mounted. From your answer it seems that you think i should rather have a user download a text file with the variables and have a “static” Apple Script parse that info and build the aliases. Right?

Thanks,

Ben

Sorry to be thick about this. As I see it now, a worker running as a client of the server would remotely create, choose or be assigned a new folder (or directory if a UNIX box) on the server, browse for the files needed for the assigned job and have aliases to each file selected (no matter which volume it might be in) appear in his work directory on the server from his “basket” of selections. Double-clicking one of these would open it on the user’s machine. Is that what you want?

Exactly :slight_smile:

Thanks.

If the server is a Mac, and its volumes are shared with the users, each user can do that him/herself. Create a job folder, name it, search for the needed files in the appropriate volumes on that machine, and create aliases in the job folder. Is this not the case?