Hello Markus,
With the newest version we have scripting capabilities in some of the tools, so yes it can be done easily.
We will use the
Edit Info Fields batch tool.
Start it and enable the field to where you want to extract the folder name.
Now click the right pointing arrow, at the right of the field, and click the "Manage scripts" item. The help topic linked above don't reflect yet this new functionality, so take a look to the first attached screenshot to better understand what I'm talking about.
In the script editor that will show up create a new script and name it
FolderName, and in the editor put this code
function FolderName() {
var parts = BatchFile.Filename.split('\\');
return parts[parts.length -2];
}
So it looks like the second attached screenshot.
You can now click the run, or "Test it", button to see if it is working. Click the OK button to exit, saving the changes.
Now in the Edit Info Fields batch tool field enter the name of the function, inside square brackets, so it looks like in the third attached screenshot. In this example I'm using the Title field as the field to where the folder name will be written. Any field can be used, and you may add more functions, field reference constants or plain text to compose the field content.
And you are ready to run it
Let me know if the code needs any change, to deal with any special case you may have.