I want to move pdf-files to a folder where the foldername is the same as the filename until the _ in the filename.
The batch has to look into the filename and compare all caracters before the first _ (underscore).
If the caracters matches with a foldername move the file to that folder.
If not, create a new folder with this name.
Example filenames
Mertens John_contract_3apr17.pdf
Mertens Jake_contract_17apr17.pdf
Van de Ven Peter_Contract_24apr17.pdf
Van de Loo Ben_contract_28apr17.pdf
Example foldernames
Mertens John
Mertens Jake
Van de Ven Peter
Van de Loo Ben
I have no experience with batch-files and have found similar questions on the forum but no answer that works 100% for me.