Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Create symbolic links in the Finder via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create symbolic links in the Finder via AppleScript
Authored by: jonn8n on Dec 01, '06 12:02:09PM
That's a lot of extra, unnecessary work. Save this code as as a AppleScript application and then just drag and drop files & folders on to its icon in the Finder to create symbolic links:
on run
	open {choose file with prompt "Choose a file to create a symbolic link:" without invisibles}
end run

on open the_files
	repeat with i from 1 to (count the_files)
		try
			set posix_path to POSIX path of (item i of the_files)
			if posix_path ends with "/" then set posix_path to text 1 thru -2 of posix_path
			do shell script "ln -s " & quoted form of posix_path & " " & quoted form of (posix_path & ".sym")
		end try
	end repeat
end open
Jon

[ Reply to This | # ]
Create symbolic links in the Finder via AppleScript
Authored by: mistersquid on Dec 01, '06 05:44:16PM
: ) Thank you. My code is often verbose and plodding. (Psst: the word you're looking for is inelegant). I will post and credit your improvement on my blog.

[ Reply to This | # ]
Create symbolic links in the Finder via AppleScript
Authored by: mistersquid on Dec 01, '06 05:51:44PM

jonn8n,

Test driving the prompt branch of your script, I was excited for a second that one might be able to select multiple files in the prompt and thereby have batch file functionality.

How hard is such a thing to code and/or anyone out there willing to chuck it in?

I really have a thing for making symbolic links in the GUI.

msq



[ Reply to This | # ]
Create symbolic links in the Finder via AppleScript
Authored by: jonn8n on Dec 02, '06 02:02:22PM

The script will only use one file if you run it by double-clicking in the Finder (or launching it some other way such as opening from the Scripts menu). However, if you drag and drop items on to its icon in the Finder, then it will iterate through all of the items and make the symbolic links for each item.

Jon



[ Reply to This | # ]