Save a historic of last 10 opened windows in finder?!

Dudes, i made one applescritp for my work, and now i want to do a little upgrade!

You can read all the discussion and my script here: http://macscripter.net/viewtopic.php?id=29297

And Actual my scritp is this:


property volumeNames : "MNOPQRSTUVX"
property targetVolumeList : {"MO", "PPC", "SEO", "Planejamento", "Criacao", "Publico", "WWW", "MP3", "Projetos Dotnet", "Producao", "Desenvolvimento"}
property targetServidorList : {"srvfs-novo", "srvfs-novo", "srvfs-novo", "srvfs-novo", "srvfs-md", "srviis-md", "srviis-md", "srviis-md", "srviis-md", "srvfs-md", "srvfs-md"}

on open theFiles
	try
		set WindowsFilePath to item 1 of theFiles as text
		
		set AppleScript's text item delimiters to ":"
		set theTextItems to text items of WindowsFilePath
		set AppleScript's text item delimiters to "\\"
		set WindowsFilePath to theTextItems as string
		set AppleScript's text item delimiters to {""}
		
		set theVolume to item 1 of theTextItems
		
		
		set strFilePath to items 2 thru (theTextItems count) of theTextItems
		set AppleScript's text item delimiters to "\\"
		set finalPath to strFilePath as string
		set AppleScript's text item delimiters to {""}
		
		if theVolume is in targetVolumeList then
			repeat with i from 1 to count targetVolumeList
				if theVolume is item i of targetVolumeList then
					exit repeat
				end if
			end repeat
			set targetLetter to character i of volumeNames
		end if
		
		set windowsFinalPath to targetLetter & ":\\" & finalPath
		
		set the clipboard to windowsFinalPath
		
		
		
		tell application "GrowlHelperApp"
			set the allNotificationsList to {"Moises trabalhando"}
			set the enabledNotificationsList to {"Moises trabalhando"}
			register as application "Moises" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
			notify with name "Moises trabalhando" title "Moises transformou o caminho" description windowsFinalPath application name "Moises"
		end tell
	end try
end open



on run
	set strClipboard to the clipboard
	set strFirstLetter to first character of strClipboard
	set strLastCharacter to last character of strClipboard
	
	if strLastCharacter = "\\" then
		set strClipboard to text 3 thru -2 of strClipboard
	else if strLastCharacter = " " then
		set strClipboard to text 3 thru -2 of strClipboard
	else
		set strClipboard to text 3 thru -1 of strClipboard
	end if
	
	
	
	
	
	
	if strFirstLetter is in volumeNames then
		set o to offset of strFirstLetter in volumeNames
		set targetVolume to item o of targetVolumeList
		set targetServidor to item o of targetServidorList
	else
		display dialog "Server or file not found"
		return
	end if
	
	set AppleScript's text item delimiters to "\\"
	set theTextItems to text items of strClipboard
	set AppleScript's text item delimiters to ":"
	set strClipboard to theTextItems as string
	set AppleScript's text item delimiters to {""}
	
	set targetMacPath to targetVolume & strClipboard
	tell application "Finder"
		activate
		set mountedVolumes to list disks
		if mountedVolumes does not contain targetVolume then
			mount volume "smb://" & targetServidor & "/" & targetVolume
			
			open folder targetMacPath
			(*select targetMacPath
			select targetMacPath*)
		else
			open folder targetMacPath
			(*select targetMacPath
			select targetMacPath*)
		end if
	end tell
	
	
	
	tell application "GrowlHelperApp"
		set the allNotificationsList to {"Moises trabalhando"}
		set the enabledNotificationsList to {"Moises trabalhando"}
		register as application "Moises" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Moises 2.0"
		notify with name "Moises trabalhando" title "Moises abriu o caminho" description targetMacPath application name "Moises"
	end tell
end run

What i want is someting like that!

Whenever the script cannot run, or didn’t find the correct way to target folder, where have the code:

display dialog "Server or file not found"

I wanna open a Historic os last 10 opened folders in finder! This is possible? How i supose to save this lasts filepath? I Don’t need full historic, i need save until user shutdown or reboot!

Thanks for help!

I don’t think that’s possible. The only thing that’s close to what you want is the “recent items” menu under the apple menu. Unfortunately folders isn’t one of the things it tracks. And I can’t think of anything on the system which gets notified/modified as you go in-and-out of folders, so there’s nothing you can check there either.

Hi regulus, your forgetting the ‘Go’ menu in finder and recent folders.

As far as I can tell, the Recent folders menu items are kept in memory and the plist for Recent folders menu is updated at logout.

You can run your script at login where it can read the plist, and get the list of ten items.
The data in the plist is not human readable, its set as alias data. But that can be converted.
The script below reads the plist, gets and converts the alias data and opens the folders.

set biglist to {}

tell application "System Events"
	set plistPath to POSIX path of file "com.apple.finder.plist" of (preferences folder)
end tell
set sig_xml_ to ""
tell application "System Events"
	set rawData to (value of property list item "file-data" of property list items of property list item "FXRecentFolders" of contents of property list file plistPath)
	repeat with i from 1 to number of items in rawData
		set rawDataText to item i of rawData
		try
			set rawDataText to value of rawDataText
		on error err
			if err contains "Can't get value of {|_CFURLAliasData|:«data ****" then set OS to offset of "****" in err
			set rawDataText to text (OS + 4) thru -4 of err
			log rawDataText
			set data_xml to (run script "«data alis" & (rawDataText as text) & "»") as text
			log data_xml
		end try
		copy (data_xml as alias) to end of biglist
	end repeat
end tell
tell application "Finder" to open items of biglist

biglist

You’re absolutely right Mark. Good catch!

Thanks a lot! Thats exactly what i need!!!