Support Forums
FileSort v1.00 CMD Script - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Computer Support Topics (https://www.supportforums.net/forumdisplay.php?fid=4)
+---- Forum: Microsoft Support (https://www.supportforums.net/forumdisplay.php?fid=5)
+---- Thread: FileSort v1.00 CMD Script (/showthread.php?tid=21828)



FileSort v1.00 CMD Script - AceInfinity - 08-29-2011

Here's my newest script for sorting files by file extension into different subdirectories within a main directory.

Save this as Anything.cmd:
Code:
@echo off
@color 0B
cls

title Ace FileSort v1.00

set ver=v1.00
set var=0

echo The files in this directory will be moved into different folders
echo.
echo Do you want to continue^?
echo.
echo.   [Y] - Continue
echo.   [Q] - Quit and Exit
echo.

choice /c:YQ>nul
if errorlevel 2 goto Exit
if errorlevel 0 goto Start

:Start
md "%CD%\FileSort %ver%"
md "%CD%\FileSort %ver%\Compressed Archives"
md "%CD%\FileSort %ver%\Image Files"
md "%CD%\FileSort %ver%\Text Files"
md "%CD%\FileSort %ver%\Sound Files"
md "%CD%\FileSort %ver%\Video Files"

:Compressed Files
for %%f in (*.*) do (
if /i "%%~xf"==".rar" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".zip" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".iso" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".bin" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".cue" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".tar" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
if /i "%%~xf"==".gz" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Compressed Archives"
    set /a var+=1
    )
)

:Image Files
for %%f in (*.*) do (
if /i "%%~xf"==".tif" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Image Files"
    set /a var+=1
    )
if /i "%%~xf"==".png" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Image Files"
    set /a var+=1
    )
if /i "%%~xf"==".jpg" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Image Files"
    set /a var+=1
    )
if /i "%%~xf"==".gif" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Image Files"
    set /a var+=1
    )
if /i "%%~xf"==".bmp" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Image Files"
    set /a var+=1
    )
)

:Text Files
for %%f in (*.*) do (
if /i "%%~xf"==".txt" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".doc" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".docx" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".log" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".msg" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".readme" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".rtf" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".text" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".wps" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".wpd" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
if /i "%%~xf"==".pages" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Text Files"
    set /a var+=1
    )
)

:Sound Files
for %%f in (*.*) do (
if /i "%%~xf"==".aif" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".aiff" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".aac" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".au" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".flac" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".ogg" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".ra" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".wave" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".wav" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".wma" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".mp4" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".mp3" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".m4a" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".mid" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".midi" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
if /i "%%~xf"==".mp2" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Sound Files"
    set /a var+=1
    )
)

:Video Files
for %%f in (*.*) do (
if /i "%%~xf"==".wmv" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".avi" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".flv" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".mp4" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".mpg" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".mov" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".3gp" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".divx" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
if /i "%%~xf"==".rm" (
    move "%CD%\%%f" "%CD%\FileSort %ver%\Video Files"
    set /a var+=1
    )
)

cls
echo.
echo You have sorted %var% files. They will be available at this location:
echo.
echo.     ^> "%CD%\FileSort %ver%"
echo.
ping -n 3 127.0.0.1>nul
echo Press any key to finish...
pause>nul

:Exit



RE: FileSort v1.00 CMD Script - Prominent - 08-30-2011

That's a great script , just tested it !
Thanks for the share ! : )


RE: FileSort v1.00 CMD Script - AceInfinity - 08-30-2011

No problem, I could have added every possible file extension I could think of but I couldn't be bothered at the time, people are going to use it for general (common) file formats anyway I would assume.


RE: FileSort v1.00 CMD Script - Inventor - 08-30-2011

Great job, thank you for it. How long did it take to write this?


RE: FileSort v1.00 CMD Script - AceInfinity - 08-30-2011

Around 10 minutes, not very long at all, I do all sorts of things in batch


RE: FileSort v1.00 CMD Script - ScripT - 08-30-2011

Wow, just tried this. Great script.

Good job Cool.


RE: FileSort v1.00 CMD Script - AceInfinity - 08-30-2011

I have another great script that will read files from a text file line by line and delete them when the file is dropped onto the batch file. Just about done with it.


RE: FileSort v1.00 CMD Script - Prominent - 08-30-2011

Make sure to post it here when it's done : )