Files
melissa-export-tools/README.md
T

2.0 KiB

melissa-export-tools

Automation scripts for Melissa's patient export workflow.

Rename and Move PT STMT.bat

Scans a root folder for patient export directories, renames export.txt with today's date, and moves it along with all .tif files into a new dated subfolder.

What It Does

For every folder found under the root that contains an export.txt:

  1. Renames export.txtPT STMT_YYYYMMDD.txt
  2. Creates a new subfolder named PT STMT_YYYYMMDD
  3. Moves the renamed .txt file into that subfolder
  4. Moves all .tif files in the same folder into that subfolder

Expected Folder Structure

ROOT\
  <patient_id>\
    Patient\
      Export\
        export.txt       ← renamed and moved
        1000001.tif      ← moved
        1000002.tif      ← moved

After running:

ROOT\
  <patient_id>\
    Patient\
      Export\
        PT STMT_20260423\
          PT STMT_20260423.txt
          1000001.tif
          1000002.tif

Setup

  1. Place Rename and Move PT STMT.bat in the root patient folder
  2. Double-click to run — it automatically uses the folder it lives in as the root

Dry Run

The script defaults to dry run mode — it will print every action it would take without touching any files. To run for real, open the file in Notepad and change:

set "DRYRUN=1"

to:

set "DRYRUN=0"

Dry run output looks like:

[DRY RUN] No files will be changed.

Found: C:\Patients\abc\Patient\Export\.
  RENAME  export.txt  >  PT STMT_20260423.txt
  MKDIR   PT STMT_20260423
  MOVE    PT STMT_20260423.txt  >  PT STMT_20260423\
  MOVE    1000001.tif  >  PT STMT_20260423\
  MOVE    1000002.tif  >  PT STMT_20260423\

Notes

  • Uses pushd/popd to work around Windows' 260-character path length limit
  • Skips any folder whose path contains PT STMT or archive so already-processed folders are never re-processed
  • Safe to re-run — mkdir for the dated folder will silently skip if it already exists
  • Date format is YYYYMMDD (e.g. 20260423)