Skip to content

SagarBiswas-MultiHAT/virusNewFolder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

virusNewFolder — Safe persistent directory generator (stored in OS temp)

CI   Python   License   Last commit   Issues

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.

Table of contents

What this does (one-liner)

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.

Why this exists / use cases

  • 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.

Key features

  • 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 --yes tame 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.

Quick start (run now)

  1. Save virusNewFolder.py next to this README.

  2. From the same folder, run an example create command:

    python virusNewFolder.py create --count 10 --prefix sample
  3. 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).
    
  4. Open the printed path (%TEMP%\create_dirs_wb5e7erc on Windows) to inspect the sample1, sample2, … folders.

Full command reference & examples

Each example assumes the script is named virusNewFolder.py. Adjust file names if you rename it.

create

Create N directories inside an instance folder.

Options:

  • --prefix / -p: Directory prefix (default sample).
  • --count / -n: Number of directories (default 10).
  • --instance / -i: Instance folder name (default: autogenerated create_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 --yes

Always 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).

detect

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 (default sample).
  • --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_wb5e7erc

Sample 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
...

cleanup

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 (cleanup refuses to run without it).

Example:

# Delete the named instance folder.
python virusNewFolder.py cleanup -i create_dirs_wb5e7erc --yes

Options: OPTION A (recommended) and OPTION B (alternate)

OPTION A — Recommended (keep the script untouched, pass explicit args at runtime)

  • 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_startup

OPTION A is the safest path for most workflows: no hidden defaults, and turning off automation is as simple as removing the scheduled command.

OPTION B — Alternate (modify the script to add a default startup behavior)

  • Edit virusNewFolder.py to 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.

Run automatically at startup (Windows)

You can automate at logon or boot while keeping the operations safe by testing with --dry-run first.

Method 1 — Startup folder (simple, recommended)

  1. Press Win + R, type shell:startup, and press Enter to open the Startup folder.

  2. Create create_dirs_startup.bat with:

    @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
  3. Save the .bat file in the Startup folder.

  4. Reboot and confirm the directories appear (use --dry-run in your test command to confirm without changing files).

Method 2 — Task Scheduler (advanced, flexible)

  1. Open Task Scheduler.

  2. Click Create Basic Task... or Create Task... for advanced options.

  3. Give it a name such as CreateDirsAtBoot.

  4. Trigger: select At log on or At startup.

  5. Action: Start a program.

  6. Program/script: full path to python.exe (for example C:\Python39\python.exe).

  7. Add arguments:

    "H:\GitHubClones\virusNewFolder\virusNewFolder.py" create -n 10 -p sample -i create_dirs_startup
    
  8. Optionally set Start in to H:\GitHubClones\virusNewFolder.

  9. 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.

Safety, security, and ethics

  • 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.
  • cleanup and create --overwrite are destructive; they always require --yes so you must confirm intentionally.
  • The script refuses to create more than 1000 directories unless you pass --yes. Use --dry-run to preview large operations.
  • This repo is educational. Respect other users’ systems and avoid any usage that could interfere with someone else’s work.

Cleanup commands (powerful — use with care)

PowerShell:

Remove-Item "$env:TEMP\create_dirs_wb5e7erc" -Recurse -Force

Command 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.

Developer notes / internals (brief)

  • 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 as create_dirs_a1b2c3 is used.
  • detect lists 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.

Testing suggestions

  • 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 pytest tests that rely on tmp_path so they run in isolation and verify creation, detection, and cleanup behavior.

FAQ (short)

  • Q: Will this script delete anything on its own?
    A: No. It never deletes files unless you explicitly use cleanup --yes or create --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 --instance with a known name. If you omitted --instance, locate the printed base path in the log output or search %TEMP% for create_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-run first.

Contributing, license, contact

  • 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 LICENSE file 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.

Features

  • Create nested directories
  • Supports custom templates
  • Error handling for existing directories

Usage

To use the tool, run the following command:

virusNewFolder [options] [template]

About

virusNewFolder; A safe, cross‑platform CLI that creates predictable, persistent directories inside your OS temporary folder for demos, tests, and automation. Supports create/detect/cleanup, --dry-run, --overwrite/--yes, customizable prefixes/instances, startup automation helpers, clear logging, and unit tests.

Topics

Resources

Stars

Watchers

Forks

Contributors