Create folder (name derived from files)

I’m trying to get a folder action to sort dropped files into folders based on the following critera:

All files names are in this form:
blah_blah_blah.pdf

Folders are derived from filenames, and contain everything from the start up to but not including the second underscore.

For example:
test2_orange_fig1.pdf
should be placed in a folder named
test2_orange

Now, I can handle everything up to and after this point, but I can’t get a variable in the right format to create the folder with the correct name, can anyone suggest a way in.

Thanks!

Well, this is what I tried (and it works!)
I created the new subfolders in the drop folder ,
but you could create them elsewhere of course.


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Hi DutchVince

fistly, many thanks for taking the time to reply in such detail!

It works great on my local drive, but after a couple of hours of jiggering I still haven’t got it to work and send the files over to a mounted network drive. Here’s what I have so far …

The script mounts the drive no problem, the error seems to be in the file copying sections in the loop. I’ll carry on puzzling over it and report back if I crack it myself. Again, many thanks!


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]