Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old May 7, 2005, 06:13 PM   #1
macrumors regular
Join Date: Mar 2004
Location: Albuquerque, NM
Send a message via AIM to iostream.h
Consolidating files with applescript

I have tons of files in a bunch of subdirectories within a main directory. I'd like to preserve this hierarchy, but would also like to have access to these files in one chunk as aliases in another folder. Would this be possible with applescript? And if so, what would be the best way to go about it?

EDIT: Also, would it be possible to have this folder of aliases dynamically update after running the script by itself?
Macintosh Applications

Last edited by iostream.h; May 7, 2005 at 06:33 PM.
iostream.h is offline   0 Reply With Quote
Old May 7, 2005, 10:21 PM   #2
HexMonkey's Avatar
Join Date: Feb 2004
Location: New Zealand
You could use this script to create the initial aliases:

tell application "Finder"
	--Get source and destination folders
	set sourceFolder to choose folder with prompt "Please choose a source folder for the files"
	set destinationFolder to choose folder with prompt "Please choose a destination folder for the aliases"
	set theItems to every item of sourceFolder
	--Iterate through the items in sourceFolder
		set nextItem to first item of theItems
		--First check that the item is not destinationFolder so that we don't make aliases of the aliases
		if (nextItem as string is not destinationFolder as string) then
			if ((class of nextItem) is folder) then
				--The item is a folder, so add its files to the end of the array
				set theItems to theItems & every item of nextItem
				--The item is a file, so make an alias of it in destinationFolder
				tell application "Finder" to make alias to nextItem at destinationFolder
			end if
		end if
		--Remove the item from the array, or exit from the loop if it's the last item
		if ((count of theItems) is 1) then
			exit repeat
			set theItems to items 2 thru (count of theItems) of theItems
		end if
	end repeat
	display dialog "Finished created aliases" buttons "OK" default button 1 with icon 1
end tell
Having the folder of aliases automatically update would be quite complicated though. Firstly you'd need to attach a folder action to the source folder that creates aliases when items are added to the folder. It would also have to find and delete an alias when items are removed from the folder. Finally, it would have to automatically add/remove the folder action to/from its subfolders, since folder actions aren't recursive.
HexMonkey is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Consolidating files with applescript jdtx63 Mac Programming 2 Jun 23, 2011 03:09 PM
sharing files with the guest account iamrawr Mac Basics and Help 1 Feb 5, 2011 05:13 PM
Permanently Delete Files With Applescript noobsauce Mac Programming 7 Dec 30, 2010 12:11 PM
Transferring files with AppleScript?? j26 Mac Basics and Help 5 May 6, 2006 02:25 PM
Question: Parsing a file with Applescript iostream.h Mac Programming 1 May 5, 2005 04:32 AM

All times are GMT -5. The time now is 10:48 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC