Move Files into new Folders based on Extension

If you ever end up with a bunch of files in a folder, but want to organize those files into their own folders, here's a quick script to help you out. In this example, I had a bunch of .ISO files in a folder and I wanted each .ISO in its own subfolder named the same thing as the .ISO file but without the extension.

 

@echo off
for /f "delims=." %%i in ('dir /b *.iso') do (
    echo Creating "%%i"
    mkdir "%%i"
    echo Moving "%%i.iso" to "%%i"
    move "%%i.iso" "%%i"
)

Note that since the script uses "." as a delimiter, it will not work on files with extra periods in the filename.



Back to Article Index

blog comments powered by Disqus