Netflix Media Downloader (NMD) can automatically run a script every time a download finishes.
This is useful if you want NMD to:
- Copy finished downloads to another drive or folder
- Start a transcoding or conversion process
- Send you a notification
- Run any other custom tool or workflow after a download completes
You only need to set this up once. After that, NMD will run your script automatically every time a transfer finishes.
Enabling a Post‑Download Script
Open Settings in the NMD.
Find the Post‑Download Script section, under the downloads tab.
Click on the text box and choose the script file you want NMD to run. Then select Open.
Once selected, NMD will run this script automatically after every completed transfer.
To stop using a script later:
In the same Post‑Download Script section, select the X to clear and stop using your script.
Important:
There is only one post‑download script setting for the whole app. The same script runs for all downloads.
Script Time Limit (Timeout)
Your script might take some time to run, especially if it’s copying large files or doing heavy processing.
You can decide how long NMD should allow the script to run before stopping it:
In Settings, go to the Post‑Download Script section. Then locate the Script timeout dropdown. Select your time limit. Remember No limit means NMD will not stop your script, even if it hangs or runs forever. If you’re doing long operations (like copying to a slow external drive), you may need a longer timeout or No limit.
What Information Your Script Receives
When a download finishes, NMD sends information about that transfer to your script as environment variables.
All variables start with NMD_. Here’s what you can use in your script:
| Variable | What it is |
| NMD_TRANSFER_ID | Internal ID for the finished transfer |
| NMD_MOVIE_ID | Movie ID |
| NMD_MOVIE_TITLE | Movie title |
| NMD_DOWNLOAD_PATH | Full path to the download folder on your computer |
| NMD_FILE_LIST | JSON list (array) of all downloaded file paths |
| NMD_FILE_COUNT | Number of files that were downloaded |
In other words:
- You can know which movie finished.
- You can know where the files are stored.
- You can know how many files were downloaded.
- You can get a full list of each file’s path if you need it.
Writing a Script (By Platform)
You’ll need a basic script file. How you write it depends on your operating system.
macOS / Linux (Bash)
Make sure your script is executable.
chmod +x /path/to/your-script.sh
Start your script with a shebang line and reference variables using $NMD_*:
#!/bin/bash
echo "Transfer ${NMD_TRANSFER_ID} completed for '${NMD_MOVIE_TITLE}'"
echo "Files are at: ${NMD_DOWNLOAD_PATH}"
echo "Total files: ${NMD_FILE_COUNT}"
Windows (Batch)
@echo off
echo Transfer %NMD_TRANSFER_ID% completed for %NMD_MOVIE_TITLE%
echo Files are at: %NMD_DOWNLOAD_PATH%
Windows (PowerShell)
Write-Host "Transfer $env:NMD_TRANSFER_ID completed for '$env:NMD_MOVIE_TITLE'"
Write-Host "Download path: $env:NMD_DOWNLOAD_PATH"
Example: Copy the Download to Another Folder (macOS / Linux)
A ready-to-use example script is included at scripts/post-download-copy.sh. It copies the completed download folder to a new directory with "-copy" appended to the name:
#!/bin/bash
DEST="${NMD_DOWNLOAD_PATH}-copy"
echo "[post-download] Copying ${NMD_DOWNLOAD_PATH} -> ${DEST}"
rsync -a --exclude='.DS_Store' "${NMD_DOWNLOAD_PATH}/" "${DEST}/"
echo "[post-download] Done. ${NMD_FILE_COUNT} files copied."
If this copy takes longer than 5 minutes, set the Script timeout to "No limit" — or background the copy so the script exits immediately:
#!/bin/bash
nohup rsync -a "${NMD_DOWNLOAD_PATH}/" "${NMD_DOWNLOAD_PATH}-copy/" \
> /tmp/nmd-copy.log 2>&1 &
echo "Copy started in background (PID $!)"
Tips & Limits
Timeout Reminder
- By default, scripts run with no time limit.
- You can change this under Settings → Script timeout.
- Options are: No limit, 5 min, 15 min, 30 min, 1 hr.
- If you leave it at No limit and your script hangs, it will keep running until you manually stop it.
NMD Does Not Wait for the Script
- Your script runs in the background.
- NMD does not wait for it to finish.
- The user interface stays responsive; downloads and other tasks continue normally.
Errors in Your Script
- If your script fails and exits with an error, NMD logs the error but keeps working.
- If you think your script isn’t running, check the NMD logs for details.
Paths with Spaces
Download folders may contain spaces in their names (for example, My Movie Title).
To avoid problems:
- Always put variable references in quotes in your script. This prevents paths like C:\My Movies\Movie 1 from being misread as separate words
Working with the List of Files
If you need to process each individual file (not just the folder), use NMD_FILE_LIST. It contains a JSON array of all file paths.
macOS / Linux with jq
echo "$NMD_FILE_LIST" | jq -r '.[]' | while read -r file; do
echo "File: $file"
done
Windows PowerShell
$files = $env:NMD_FILE_LIST | ConvertFrom-Json
foreach ($file in $files) {
Write-Host "File: $file"
}
File List Shows the Whole Folder, Not Just the Latest Transfer
When NMD runs your post‑download script, it gives you two values:
- NMD_FILE_LIST – a list of file paths
- NMD_FILE_COUNT – the number of files
Important:
Right now, these do not represent “only the files from this most recent transfer.”
Instead, they represent all files currently in the target download folder.
What this means in practice:
- If you start with an empty folder and run Transfer A (10 files):
- NMD_FILE_LIST will contain those 10 files.
- Later, you run Transfer B to the same folder (another 10 files, now 20 total in that folder):
- NMD_FILE_LIST will now contain all 20 files in that folder (the old 10 + the new 10).
So each time NMD runs your script, it’s giving you a snapshot of everything in the target folder at that moment, not just “what was downloaded this time.”
If you never change NMD’s default download folder (for example, your general Downloads directory), then:
- NMD_FILE_LIST will include all files in Downloads, not just NMD’s files or just the latest transfer.
- Every new download just adds more files to that same directory, and the script sees all of them.
How to work with this behavior
Given the current behavior:
- If you want NMD_FILE_LIST to only contain files from a single transfer, make sure:
- You point NMD to a dedicated empty folder for that workflow or transfer.
- Your post‑download script cleans up (moves or deletes) the files when you’re done with them.
If you’re reusing the same folder and keeping older files there:
- Your script will need to compare (“diff”) the current list of files against what was there before to figure out which ones are new.