If you’ve moved to a digital lifestyle, and are an archivist, then you are probably downloading tons of data these days. Everything from music to movies to comics to games to images to software to emulator roms to books to articles.

Sorting stuff manually is stupid. Sort things (take a folder full of crap, and sort it intelligently into subfolders) with a script. Assimilate (move subfolders to correct repositories) with a script.

I’m not going to share my scripts. But here is a great pattern for sorting files into subfolders. I’ll use an example that deals with My Little Pony related files:

set TARGETDIR=MLP
unset /q MASK
gosub addMask "My Little Pony*.*"
gosub addMask "MLP*.*"
gosub addMask "Equestria*.*"
gosub addMask "*Rainbow Dash*"
if "%MASK%" ne "" if not isdir %TARGETDIR% md %TARGETDIR%
if "%MASK%" ne "" mv  %MASK% %TARGETDIR%

This pattern can be copied over for anything. Simply change TARGETDIR to whatever folder you want. And use the addMask function to add wildcards that match those kinds of files.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:addMask [newMask]
	:Don't bother doing anything if no files match:
	if not exist %newMask% goto :addMaskReturn
	:Otherwise, add mask for those files to our mask list:
	if "%MASK%" eq "" goto :Empty_YES
	                  goto :Empty_NO
		:Empty_YES
		    set MASK=%newMask%
		    goto :Empty_DONE
		:Empty_NO
		    set MASK=%MASK%;%newMask%
		:Empty_DONE
:addMaskReturn
return
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Note that all my scripts are meant to be run on JPSoft‘s TakeCommand command-line interpreter (descended from 4NT in the 2000s, which was descended from 4DOS in the late 1990s, which was descended from NDOS, the command.com replacement included in Norton Utilities in the late 1980’s). This would probably work with CMD.EXE or PowerShell, but I haven’t tested those.

Use this pattern to make a giant sortthese.bat that sorts everything everywhere. If you want to get fancy, centralize all the scripts into one script that examines the current path and branches based off of that. (It’s easier to keep backups if everything is in one place.)

Here’s an example of branching based off the location where you invoke a script:

::::: Determine assimilate role:
if "%_CWD"==  "%HD250G:\READY-TO-DELETE"                goto :assimilate_dvd-burned_media
if "%_CWD"==  "%HD250G:\ABOUT-TO-BE-BURNED\DATA\BURNED" goto :assimilate_dvd-burned_data
if "%_CWD"=="%HD2000G5:\ABOUT-TO-BE-BURNED\DATA\BURNED" goto :assimilate_bluray-burned_data
if "%_CWD"==  "%HD256G:\MEDIA\MOVIES"                   goto :assimilate_freshly_watched_movies
if "%_CWD"=="%HD1500G2:\MEDIA\MOVIES"                   goto :assimilate_freshly_watched_movies
if "%_CWD"== "%HD2000G:\MEDIA\MOVIES"                   goto :assimilate_freshly_watched_movies
if "%_CWD"== "%HD1000G:\downloadclient\completed"       goto :assimilate_fresh_downloads

^ That code may be confusing-looking because I never hard-code drive letters. All my harddrives have environment variables which evaluate to the correct letter depending on which computer you are on. Also, %_CWD is TakeCommand’s variable that is the current folder you are in. That does NOT work in CMD.EXE. CMD.EXE uses something else, so this would need some modificationMusic: Ministry – No Glory (Sandpaper Condom Mix)