Droplet or select folder


to getFilePath(choose folder with prompt "Please select the a folder:")
end getFilePath
set thePath to getFilePath()
return

on open of finderObjects -- "open" handler triggered by drag'n'drop launches
	repeat with i in (finderObjects) -- in case multiple objects dropped on applet
		tell application "Finder"
			duplicate file i to folder of "Desktop"
		end tell
	end repeat
end open

This won’t compile, but I think you get the idea of what I’m trying to do.

My final goal is this: Upon first run or first drop of files, ask for a folder to copy to and store that path within a .app/Contents/Resources/ATextFileContainingThePath script.
Then, any drop will copy files to the set folder. In case of a non-drop it will ask for another folder to change the path to copy to to.

Any input on how to fix what I have now would be great.

TIA

Everytime the script runs, I would read the file. If there is no path, ask for one and save it to the file.

Thanks anyhow, but another friend helped me out…
Heres the result:


property thePath : null
property msg : "Please select a folder:"
on run
	if thePath is equal to null then
		set thePath to choose folder with prompt msg
	else
		set thePath to choose folder with prompt msg default location thePath
	end if
end run
on open DroppedItems
	if thePath is equal to null then
		set thePath to choose folder with prompt msg
		tell application "Finder"
			duplicate DroppedItems to thePath
		end tell
	else
		tell application "Finder"
			duplicate DroppedItems to thePath
		end tell
	end if
end open

That may work, but it doesn’t meet your goal of asking for a path on first run and storing it so that future runs use that path.

It does work… See the property at the top?
It doesn’t store the path in a file, it stores it in itself… Property values persist over different runs.