virusNewFolder is a carefully designed command-line utility that generates persistent directories inside your operating system's temporary folder. The directories remain after the process exits so you can inspect, reuse, or delete them manually when you are done.
- What this does (one-liner)
- Why this exists / use cases
- Key features
- Quick start (run now)
- Full command reference & examples
- Options: OPTION A (recommended) and OPTION B (alternate)
- Run automatically at startup (Windows)
- Safety, security, and ethics
- Cleanup commands (powerful — use with care)
- Developer notes / internals (brief)
- Testing suggestions
- FAQ (short)
- Contributing, license, contact
Creates named directories PREFIX1, PREFIX2, … PREFIXN inside a persistent create_dirs_* instance folder under your OS temporary directory (for example: C:\Users\<you>\AppData\Local\Temp\create_dirs_a1b2c3\sample10). These directories remain after the script exits unless you explicitly remove them.
- Quickly create predictable artifacts for demos, teaching, or local tooling without interfering with project files.
- Keep everything in the OS temp folder so the experiment data stays isolated and easy to delete.
- Provide a low-effort way to reproduce filesystem stress tests or run simple automation while leaving a clear trail of what was generated.
- Persistent storage inside the OS temp folder (
tempfile.gettempdir()drives the base path). - Cross-platform behavior for Windows, macOS, and Linux without code changes.
- Subcommands:
create,detect,cleanup. - Safety switches:
--dry-run,--overwrite, and--yestame destructive or large operations. - Fully customizable prefixes, counts, and instance names.
- Clear logging that always prints the base path so you can inspect the output manually.
-
Save
virusNewFolder.pynext to this README. -
From the same folder, run an example create command:
python virusNewFolder.py create --count 10 --prefix sample
-
The command prints the base path and each directory it creates:
INFO: Base instance directory: C:\Users\<you>\AppData\Local\Temp\create_dirs_wb5e7erc INFO: Creating: C:\Users\<you>\AppData\Local\Temp\create_dirs_wb5e7erc\sample1 ... INFO: Operation complete: 10/10 created (created/skipped). -
Open the printed path (
%TEMP%\create_dirs_wb5e7ercon Windows) to inspect thesample1,sample2, … folders.
Each example assumes the script is named virusNewFolder.py. Adjust file names if you rename it.
Create N directories inside an instance folder.
Options:
--prefix/-p: Directory prefix (defaultsample).--count/-n: Number of directories (default10).--instance/-i: Instance folder name (default: autogeneratedcreate_dirs_<suffix>).--dry-run: Show what would be created without writing to disk.--overwrite: Delete matching directories and recreate them (requires--yes).--yes: Confirm large or destructive operations (--overwrite, counts > 1000, etc.).--verbose/-v: Emit more logging for debugging.
Examples:
# Create 10 persistent sample* directories in temp.
python virusNewFolder.py create --count 10 --prefix sample
# Create 100 directories with a fixed instance name so the path never changes.
python virusNewFolder.py create -n 100 -p sample -i create_dirs_wb5e7erc
# Preview without performing filesystem work.
python virusNewFolder.py create -n 50 --dry-run
# Overwrite existing sample* directories (dangerous) — must pass --yes.
python virusNewFolder.py create -n 20 -p sample --overwrite --yesAlways note the logged base instance path. Reusing --instance create_dirs_wb5e7erc guarantees the same folder (for example: C:\Users\<you>\AppData\Local\Temp\create_dirs_wb5e7erc\sample10).
List directories that match a prefix inside the chosen instance. Each entry shows the number of child items and the last modification timestamp.
Options:
--prefix/-p: Prefix to filter (defaultsample).--instance/-i: Instance folder to inspect (default: the autogenerated instance from that run).
Examples:
# Inspect the default instance for "sample*" directories.
python virusNewFolder.py detect -p sample
# Inspect a specific instance folder by name.
python virusNewFolder.py detect -p sample -i create_dirs_wb5e7ercSample output:
INFO: Found 10 matching directories in C:\Users\<you>\AppData\Local\Temp\create_dirs_wb5e7erc
C:\Users\<you>\AppData\Local\Temp\create_dirs_wb5e7erc\sample1 | entries=0 | modified=2026-02-01 12:34:56
...
Destroy the entire instance folder. This is irreversible, which is why --yes is required.
Options:
--instance/-i: Instance folder to delete (default: current instance).--yes: Confirm the destructive action (cleanuprefuses to run without it).
Example:
# Delete the named instance folder.
python virusNewFolder.py cleanup -i create_dirs_wb5e7erc --yes- Leave the script as-is.
- Configure your automation (Startup folder, Task Scheduler, scripts, etc.) to call the exact command you want.
- Because every run is explicit, you can change behavior by editing the automation entry rather than the code.
Example automation command:
python "H:\GitHubClones\virusNewFolder\virusNewFolder.py" create -n 10 -p sample -i create_dirs_startupOPTION A is the safest path for most workflows: no hidden defaults, and turning off automation is as simple as removing the scheduled command.
- Edit
virusNewFolder.pyto detect when no subcommand is supplied and perform a default run.
if args.command is None:
base_dir = ensure_base_dir("create_dirs_startup")
create_directories(base_dir, prefix="sample", count=10)
return 0- Use this when you truly need one, consistent behavior at startup and prefer not to manage the command line.
Downsides: the behavior becomes less explicit, harder to audit, and might surprise someone who runs the script interactively without understanding the built-in fallback.
You can automate at logon or boot while keeping the operations safe by testing with --dry-run first.
-
Press
Win + R, typeshell:startup, and press Enter to open the Startup folder. -
Create
create_dirs_startup.batwith:@echo off REM Create 10 persistent sample directories at boot python "H:\GitHubClones\virusNewFolder\virusNewFolder.py" create -n 10 -p sample -i create_dirs_startup exit
-
Save the
.batfile in the Startup folder. -
Reboot and confirm the directories appear (use
--dry-runin your test command to confirm without changing files).
-
Open Task Scheduler.
-
Click Create Basic Task... or Create Task... for advanced options.
-
Give it a name such as
CreateDirsAtBoot. -
Trigger: select At log on or At startup.
-
Action: Start a program.
-
Program/script: full path to
python.exe(for exampleC:\Python39\python.exe). -
Add arguments:
"H:\GitHubClones\virusNewFolder\virusNewFolder.py" create -n 10 -p sample -i create_dirs_startup -
Optionally set Start in to
H:\GitHubClones\virusNewFolder. -
Finish the wizard and run the task manually once to verify everything works.
Use Task Scheduler when you need elevated privileges, system boot execution, or more powerful triggers.
- Do not run as Administrator/root;
%TEMP%(or the equivalent) does not require elevation. - Prefer neutral prefixes (
sample,test,demo) on shared systems and when publishing. cleanupandcreate --overwriteare destructive; they always require--yesso you must confirm intentionally.- The script refuses to create more than 1000 directories unless you pass
--yes. Use--dry-runto preview large operations. - This repo is educational. Respect other users’ systems and avoid any usage that could interfere with someone else’s work.
PowerShell:
Remove-Item "$env:TEMP\create_dirs_wb5e7erc" -Recurse -ForceCommand Prompt:
rmdir /s /q "%TEMP%\create_dirs_wb5e7erc"Bash / WSL:
rm -rf "/tmp/create_dirs_wb5e7erc"
# or, on Windows WSL mapping:
rm -rf "/mnt/c/Users/<you>/AppData/Local/Temp/create_dirs_wb5e7erc"Always verify the target path before running destructive shell commands.
- The script uses
tempfile.gettempdir()to find the OS temp directory (%TEMP%on Windows). --instance <name>controls the exact folder name; otherwise a readable auto-generated instance such ascreate_dirs_a1b2c3is used.detectlists only directories whose names start with the provided prefix and reports entry counts plus modification timestamps.- There is no persistent state beyond the directories written to disk; no database or registry interactions occur.
-
Dry-run smoke test:
python virusNewFolder.py create --count 5 --prefix test --dry-run -
Functional cycle test:
python virusNewFolder.py create -n 3 -p test -i create_dirs_test python virusNewFolder.py detect -p test -i create_dirs_test python virusNewFolder.py cleanup -i create_dirs_test --yes
-
Add
pytesttests that rely ontmp_pathso they run in isolation and verify creation, detection, and cleanup behavior.
-
Q: Will this script delete anything on its own?
A: No. It never deletes files unless you explicitly usecleanup --yesorcreate --overwrite --yes. -
Q: Can I run it as a background service or daemon?
A: You can convert it to an executable and register it as a service, but Task Scheduler or the Startup folder is easier for routine startup tasks. -
Q: How do I get the exact path used last time?
A: Always pass--instancewith a known name. If you omitted--instance, locate the printed base path in the log output or search%TEMP%forcreate_dirs_*. -
Q: Is it safe to run on a work machine?
A: Yes, operations are non-destructive by default. Still, follow your organization’s policies, use neutral prefixes, and test with--dry-runfirst.
- Contributions: Open a pull request with a clear description, intent, and tests. Keep the safety checks intact.
- License: MIT (or your preferred license). Add a
LICENSEfile when publishing. - Contact: Need help with tests, CI, or packaging the script? Open an issue and explain what you want to accomplish.# virusNewFolder Tool
The virusNewFolder tool is designed to create a full directory structure based on a specified template.
- Create nested directories
- Supports custom templates
- Error handling for existing directories
To use the tool, run the following command:
virusNewFolder [options] [template]