Skip to content

Instantly share code, notes, and snippets.

@sidward35
Created January 9, 2019 07:58
Show Gist options
  • Save sidward35/5dc4173ab1849f1e00fabadb84cb91dd to your computer and use it in GitHub Desktop.
Save sidward35/5dc4173ab1849f1e00fabadb84cb91dd to your computer and use it in GitHub Desktop.
Batch script that sorts files into folders by file type
@echo off
rem For each file in your folder
for %%a in (".\*") do (
rem check if the file has an extension and if it is not our script
if "%%~xa" NEQ "" if "%%~dpxa" NEQ "%~dpx0" (
rem check if extension folder exists, if not it is created
if not exist "%%~xa" mkdir "%%~xa"
rem Move the file to directory
move "%%a" "%%~dpa%%~xa\"
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment