Create a folder named from a dragged file, and copy file inside

Here’s the challenge… using AppleScript/Automator/whatever… drag a file onto a droplet/app, and it creates a folder with that file’s name, and puts the file in it. So far, all “nearly” similar posts and articles here, AutomatorWorld, Apple Discussions, etc, haven’t turned anything up. Has anyone figured out a good way to do this?

–Douglas

Hi Douglas,

try this droplet, save it as application.
You will prompted to choose the destination folder

on open theseFiles
	set destFolder to choose folder
	repeat with theFile in theseFiles
		set {isFolder, theName, ext} to {folder, name, name extension} of (info for theFile)
		if ext is not "" then set theName to text 1 thru ((count theName) - (count ext) - 1) of theName
		if isFolder is false then
			tell application "Finder"
				set newFolder to make new folder at destFolder with properties {name:theName}
				move theFile to newFolder
			end tell
		end if
	end repeat
end open

Stephan,

That is great, thank you. It seems so simple, and although I’m not much of an AppleScripter, I feel I should have figured it out. I’m going to go over the other partial attempts I’d made and see what I missed. Much appreciated.

–Douglas