1.

Solve : Command line to create a folder with the name of a file?

Answer»

Friends, friends... I don't know if it is possible. But it will be of great help.

I have some some folders, subfolders and a zip file in each subfolder. SOMETHING like -

Main - Sub 1 - 1.zip
Main - Sub 2 - 2.zip
Main - Sub 2 - subsub 2 - 2.1.zip

The naming conventions just random. I need to create a batch file to create folders inside all the folders that have a zip file in it. The newly created folder must bear the NAME of the zip file, without the extension.zip. The batch should then move all the zip files to the RESPECTIVE newly created folders.

If the above case is considered, I need the FOLLOWING result after running the batch:

Main - Sub 1 - 1 - 1.zip
Main - Sub 2 - 2 - 2.zip
Main - Sub 2 - subsub 2 - 2.1 - 2.1.zip

Any help please... This will save a lot of my time. And will ignite new ideas. ;-) Thank u all in advance.

Code: [Select]@echo off
for /f "delims=" %%a in ('dir /s /b "C:\Test\Main\*.zip"') do (
MD "%%~dpa%%~na"
move "%%a" "%%~dpa%%~na\"
)



Discussion

No Comment Found