
If the output is correct, remove the echo to make it work. If you have a file with no extension, you will not be able to create the folder, as it will have exactly the same name as the file and this is not allowed.Ĭode includes echo commands before md and move to show what will be executed. The reason for having to include a string at the end of the folder in your code is you are trying to create a folder with exactly the same name that the file (in your code, you are not removing the extension), and you can not have two elements (files or folders) inside a folder with the same name. In this code, the reason for the third if is to check if the possible previous folder creation has failed. To avoid problems with spaces in paths/file names, double quote all the references to them. %%~dpna = drive, path, and file name without extension of the current file being proccesed
#File2folder full#
%%~fa = full path of the file being processed if the target folder exist, move the file to the folder.if not exist a folder with the same name that the file, create it.If not exist "%%~dpna\" echo md "%%~dpna"


To avoid problems with spaces in paths/file names, double quote all the references to them.
