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


Click here to return to the 'Move selected items into ready-to-rename folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Move selected items into ready-to-rename folder
Authored by: mark hunte on Apr 03, '09 09:54:56AM
Here is a quick change to set the name ...

(*
Move items into new folder
Author: Barry Els
Version: 1.1
*)
global newName, dialogue
set newName to "Untitled Folder"
set dialogue to "Enter New Name"
tell application "Finder"
	try
		
		set theSelection to selection
		
		set currentPath to container of (the first item of the theSelection) as alias
		set parentPath to currentPath
		try
			
			my getNameset(currentPath)
			set newFolder to (my createFolder(parentPath))
			
			move theSelection to newFolder
			
			delay 0.1
			set selection to newFolder
			--- tell application "Finder" to activate --- for testing
			tell application "System Events"
				
				keystroke return
			end tell
			
		end try
		
	on error
		(*
    no folder or file is selected, warn the user
    *)
		
		display dialog ("Please select one or several items to group" & (theSelection as string))
		
	end try
	
end tell
on getNameset(currentPath)
	
	tell application "Finder"
		set newName to text returned of (display dialog dialogue default answer newName buttons {"Cancel", "OK"} default button 1)
		if (exists (folder newName of currentPath)) then
			set dialogue to "A item with that name exists Already"
			my getNameset(currentPath)
		end if
	end tell
end getNameset

on createFolder(selectedPath)
	
	tell application "Finder"
		
		set createdFolder to make new folder at selectedPath with properties {name:newName}
	end tell
	
	return createdFolder
end createFolder

---
mh

[ Reply to This | # ]

Move selected items into ready-to-rename folder
Authored by: amaloney on Apr 03, '09 12:42:36PM

Thanks Mark
I'll use it.

Al Maloney



[ Reply to This | # ]
Move selected items into ready-to-rename folder
Authored by: daviddingleberry on Apr 05, '09 02:18:45PM

I love this hint, very useful;

in the script line

"set newName to text returned of (display dialog dialogue default answer newName buttons {"Cancel", "OK"} default button 1)"

I changed the the default button to 2, which allows me to hit "enter" on my keyboard to create the folder, instead of requiring me click on "OK".



[ Reply to This | # ]