Need script to switch screens position.

I want to make an applescript that sits in the side strip of the finder window. Thats the easy part. When I drag a file or folder to this applescript the file or folder should be moved to the previous folder.

For example I open the folder “Macintosh HD:Applications:” then I drag the file or folder to the applescript and the file is moved to “Macintosh HD:” because its the previos folder. I hope someone can help me with this, it could prove to be very useful.

If you read Finder’s dictionary, you’ll come with something as this:

on open list_of_files
	tell application "Finder" to move list_of_files to parent of target of window 1
end open

thanks very much, didn’t realize it would be that simple.

The Finder has a strong dictionary :smiley:

You should add some error checking to the script so that it will tell you if an item with that name already exists…

on open list_of_files
	try
		tell application "Finder" to move list_of_files to parent of target of window 1
	on error theErr
		display dialog theErr buttons {"OK"} default button 1
	end try
end open

It’s good that Greg mentioned error checking because there could be a lot that could go wrong in that script. Duplicate file names, permission issues, the window could already be the root drive and, as such, have no parent, “window 1” might not even be a Finder window, it could be the “Emptying Trash…” window or a “Get Info” window.

Jon

ok, thats cool, still works too. However sometimes the last folder/window that was open may not be the parent of the current window.

for example I open the “Macintosh HD” then I open “library:macintosh hd:” next I click the “Appications” button in the side strip so that takes me to
“Macintosh HD:Applications:” now when I drag something to the applescript and it moves to “Macintosh HD” instead of “Macintosh HD: Library:”

see what I mean? is there any fix for this?

after a fix go here:

http://www.sentman.com/backgrounder/

this drag and drop app makes applescript and other apps invisible, no dock icon

Just a guess, but you might be looking for enclosing folder

Yes, but it lacks a thesaurus! :smiley:

thats what the “parent folder” is, I want the last folder visited

almost the same, but not quite.

To get the last folder (as used by the forward & backward buttons in Finder windows in OS X 10.3.x), I suspect you’re going to have to read the Finder prefs file.

Jon

any ideas on how to do this?
what about the “recent folders” from the go menu?

I think it is part of the “com.apple.finder.plist” file in the local user’s prefs folder (~/Library/Preferences/com.apple.finder.plist) but that is quite a beast to traverse. Um, I’m not certain why this is so appealing to you. I find it much easier to copy & paste the file into my target location (highlight the file, Command-C, move back via the history button or however you get to the target folder, and hit Command-V) or to use the spring loaded folders to move/copy the file(s).

Good luck,
Jon

bump