it seems I just can’t find how to tell this.
I’m using (on open items) to drag files on my script
I want to create a folder in the folder from where the files where dragged.
need help on this please.
it seems I just can’t find how to tell this.
I’m using (on open items) to drag files on my script
I want to create a folder in the folder from where the files where dragged.
need help on this please.
sbriss:
What have you tried so far?
set MyFolder to make new folder at folder of MyFiles
(permission denied, cause it try to create a folder after the name of MyFiles)
similars things!
I think what i have to do is to remove the name of the file in the path to the file. This way i’ll be able to create a folder there.
I hate to be stocked with this kind of things!
There are several ways to do this but an easy one is to use “container of”. Files are in a container, which is their parent folder.
Here is a very simple example. Select a file on your Desktop and run this.
tell application "Finder"
set r to (selection as alias)
set n to make new folder at (container of r) with properties {name:"sbriss Folder"}
end tell
Note: I, out of habit, push things like making folders into variables for easy reference later in the script but it’s not required (and some values don’t need to be cached like this. OTOH, variables are cheap)
Also, note that this is not how I would do it nowadays but it’s still tried and true for pure Applescript.
And also, also, note that there is no error checking here so you will need to check for this existence of folders in the location you’re trying to write to. This is pretty trivial (and where caching values up front comes in handy). I’ll leave the error traps to you.
Cheers!
Jim
BLUEFROG
Thank you, it works.