Drag and drop file paths

Hello I’m new to AppleScript Studio, so please forgive give me if these seem like stupid questions. I have just begun to write an interface in ASS based on drag and drop. Here is how I Imagine the finished result will work.

Operator drags a file (s) from a file server onto the interface table

Selected file names are displayed in the table

Operator clicks submit

New window is displayed containing the selected files at one side and tasks to be performed on them at the other.

Once a task has been selected the operator hits “Done!”

In the background the script extracts the file path to the select file(s) and puts it into a “do shell script command”. Something like this:

Do shell script "rsh 10.XX.X.XXX -l loginname cp selectedfilespath
Staticfilepathofhotfolder”

In addition to this I would like the task selected to add a naming convection to the front of the selected files name on copy (So the HF knows what to do with it)

As a starting point for this I have used the drag and drop from Apples examples and strip off the bits I don’t need. The main problem I have at the moment is extracting the file path of the selected files. If anyone can help with this or has any ideas that might help me I would be eternally grateful.

Thanks Clever People! :shock:

Assuming your conclude drop (or whichever handler you are using) looks something like this:

on conclude drop theObject drag info dragInfo
set preferred type of pasteboard of dragInfo to “file names”
set theFiles to contents of pasteboard of dragInfo
end conclude drop

then theFiles should be a list of the posix filenames (with their paths)…

You could then call something like:

to getPath(theFullName)
set AppleScript’s text item delimiters to “/”
set theParts to theFullName’s text items
set theCurrentPath to items 1 through ((count of theParts) - 1) of theParts as string
set AppleScript’s text item delimiters to {“”}
return theCurrentPath
end getPath

to get the path of each item of theFIles…

There’s probably a better way of doing it, but the above works for me…

Thanks for the advice, how do I get these two handlers to interact i.e display the file paths of the files dragged onto the table?

Cheer

J :oops:

The handler ‘on conclude drop’ is probably already being called in your applescript. Have a look and see what is already in there.

Have you got a data source for your table contents? All you should really need to do is loop throught the ‘theFiles’ list in the ‘conclude drop’ handler and call the ‘getPath’ function with each item, and add the result to your data source to get it into your table…