Modern Projects, Fossilized DNA
As an optimization-obsessed tinkerer, I was recently thinking about my personal workflows. One of my biggest personal points of friction is deciding a project structure. I try to decide what's best based on the project's requirements, but I have a tendency to take too much time trying to find the perfect solution. Additionally, there's always common overlap in the boilerplate file structure, which led me to a simple idea. One command to handle all the common overlapping boilerplate for all the different languages and frameworks I use. What started as a utility quest for a project directory builder turned into an archaeological dig into 1980s automation.
IF /I "%~1" == "" GOTO :USAGE
IF /I "%~1" == "help" GOTO :USAGE
REM Python
IF /I "%~2"=="--python" (
if exist "%~1\" (
echo ERROR: Folder "%~1" already exists.
exit /b 1
)
md "%~1"
pushd "%~1"
md "docs" "src" "tests"
echo # %~1 > "README.md"
type nul > "LICENSE"
popd
echo [+] Created Python project folder: "~%1"
exit /b 0
)A snippet from the
newtoybatch script.
Batch's Quirks
Batch is essentially the fossilized DNA of MS-DOS, dating back to the early 80s. While it certainly shows its age, there is a strange elegance in how it handles the basics once you get past the archaic syntax.
The REM Mystery
The most visible quirk is the REM command. Short for "Remark," this is a holdover from early programming languages like BASIC. Unlike modern languages that use symbols (like # or //), Batch treats comments as a command that tells the interpreter to ignore the rest of the line.
REM This is a comment.
REM It stands for "Remark" and is a literal command to the shell.
:: <-- Double colons is actually a common shorthand for REM,
:: but it's technically a "broken label" that developers use as a hacky shorthand symbol.Surprisingly Elegant Argument Processing
One thing that caught me off guard was how simple it is to process arguments. Using %~1 and %~2 allows you to grab inputs and even strip surrounding quotes automatically—which is arguably more straightforward than some modern boilerplate.
:: Checking for the --python flag in the second argument (%~2)
IF /I "%~2"=="--python" (
md "%~1"
pushd "%~1"
md "docs" "src" "tests"
popd
echo [+] Created Python project folder: "%~1"
)Non-Traditional Function Definitions
Defining "functions" in Batch feels different than what I’m used to, but it has a pragmatic charm. You essentially use labels (indicated by a colon) and exit /b to return control, making it easy to create reusable blocks like a usage guide.
:USAGE
echo.
echo Usage: newtoy [project_name] --[project_type]
echo Example: newtoy cool_project --python
exit /b 0The Evolution of Structure
The real value of this "archaeological" foray wasn't just the automation itself, but the standardization it forced me to confront.
Before this, I didn't have a pre-defined folder or file structure for my projects. In the process of building newtoy, I had to research what a "good" project actually looks like. While I started with Python, I quickly discovered the debate between flat layouts and src layouts.
I’ve landed on src-based layouts as my preference for now, so I’ve baked that logic directly into the script.
This script serves as a living document of my "known good" project state. As my preferences change or I pick up new languages, the automation will evolve with me. Additionally, it’s a reminder that automation doesn't always require the latest shiny framework. Sometimes, reaching for a 40-year-old tool is the fastest way to remove current friction and establish a repeatable workflow.
I’ll be adding more project types to the repo as the need arises. For now, I’m just happy to have one less "manual" step between an idea and the first line of code.
Repo: bju12290/cmd-tools