I want to set up a handbrake instance on my 2014 macmini to process my entire tv show library and format it to a preset. Help me accomplish this in the easiest way possible such that it doesn't crash my computer and slowly works its way through the library. I would prefer a solution that can replace the files automatically in my library and be aware of the files that have been processed
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Of course. This is a perfect task for automation, and doing it correctly is key on an older machine like a 2014 Mac Mini to prevent crashes and ensure it completes.
The biggest challenges with your Mac Mini will be heat and CPU load over a very long period. We need a solution that is "slow and steady" and robust enough to handle interruptions.
We will use a command-line script to do this. It sounds intimidating, but it's the most reliable and resource-friendly way. It will process one file at a time, verify it was successful, and then replace the original. This is much safer for your computer than loading up the HandBrake GUI with hundreds of files, which can consume a lot of memory and crash.
Here is the easiest, most reliable way to accomplish your goal.
Strategy Overview
Backup First: This process will replace your original files. YOU MUST HAVE A BACKUP.
Install HandBrake Command-Line Tools: We'll use the powerful HandBrakeCLI.
Create Your Perfect Preset: You'll use the regular HandBrake app to create and export your desired video preset.
Use a Smart Script: I will provide you with a script that you can copy and paste. This script will:
Find all video files in your library.
Process them one-by-one using your preset.
Run at a low CPU priority to keep your Mac usable (nice).
Check if the new file was created successfully.
If successful, it will delete the old file and rename the new one.
If it fails, it will log the error and skip to the next file.
It automatically knows which files have been processed because the original files will be gone.
Step 1: CRITICAL - Backup Your Library
Before you do anything else, please back up your entire TV show library to an external hard drive. The script we're creating is destructive—it deletes the original files after a successful conversion. If something goes wrong or you don't like the quality of the preset, you will have no way to go back without a backup.
Step 2: Install HandBrake and the CLI
Download and Install HandBrake: If you don't already have it, download the standard HandBrake application from the official HandBrake website.
Make the Command-Line Tool (CLI) Accessible: The command-line version (HandBrakeCLI) is included inside the application you just downloaded. We need to make it easy to use from the Terminal.
Open the Terminal app (you can find it in /Applications/Utilities/ or by searching with Spotlight).
Copy and paste the following command into the Terminal and press Enter. This creates a symbolic link, which is like a shortcut, to the tool.
It will ask for your password. This is your Mac login password. You won't see characters as you type; this is normal. Press Enter.
Step 3: Create and Export Your HandBrake Preset
Now, let's create the settings you want to apply to all your shows.
Open the regular HandBrake application.
Drag one of your TV show files into HandBrake so you can see the settings.
In the "Preset" panel, select a base preset to start from (e.g., Fast 1080p30).
Adjust all the settings you want: Video (encoder, quality), Audio (tracks, encoding), Subtitles, etc.
When you are perfectly happy with your settings, click the "Save New Preset" button.
Give it a memorable name (e.g., My TV Show Preset), set the category, and click Save.
This is the most important part: In the "Presets" menu at the top of the screen, click on your new preset, and then click the options icon (three dots) next to it and choose "Export to File".
Save this file somewhere you can easily find it, like your Documents folder. Let's say you name it mytvpreset.json.
Step 4: The Automation Script
This is the engine of the operation. It will do all the heavy lifting.
Open the Terminal app again.
Type nano process_shows.sh and press Enter. This will open a simple text editor inside the Terminal.
Copy the entire script below and paste it into the Terminal window.
bash
VERY IMPORTANT: You must edit the first 3 variables at the top of the script.
TV_SHOWS_DIR: Change /path/to/your/tv_shows to the actual path of your library. You can get this by dragging the folder into the Terminal window.
PRESET_FILE: Change /path/to/your/mytvpreset.json to the path of the .json file you exported.
OUTPUT_EXTENSION: Set this to mp4 or m4v, matching what your preset is configured to create. The script will skip any files that already have this extension, which is how it knows what's already done.
Save and Exit Nano:
Press Ctrl + O (the letter O, not zero) to Write Out (save).
Press Enter to confirm the filename.
Press Ctrl + X to exit.
Step 5: Run the Script Safely
This process will take days, or even weeks. You cannot just run it in a standard Terminal window because if you close the window or your Mac goes to sleep, the process will be killed. We will use a tool called screen which comes pre-installed on your Mac.
Make the script executable: In Terminal, run this command:
bash
chmod +x process_shows.sh
Start a screen session: This creates a virtual terminal session that will keep running in the background.
bash
screen -S handbrake
Your terminal window will clear and you'll be inside the screen session. It looks the same, but it's persistent.
Start the script:
bash
./process_shows.sh
Monitor the Progress: You will see the script start printing its progress. You can also open the log file it creates on your Desktop (handbrake_conversion.log) to see detailed output from HandBrake.
Detach from the screen session: Now for the magic. You can safely "disconnect" from this session and it will keep running in the background.
Press Ctrl + A, then let go, and then press D (for detach).
You are now back in your normal terminal. The script is still running in the background, chugging away at your files one by one, at a low priority. You can close the Terminal window and even log out.
How to Check on the Process Later
Any time you want to see how it's doing, open a new Terminal window and type:
bash
screen -r handbrake
This will "re-attach" you to the running session, and you'll see the current progress. When you're done looking, just detach again (Ctrl + A, then D).
Final Important Considerations for your Mac Mini
Heat: A 2014 Mac Mini can get hot during prolonged encoding. Place it on a hard surface and consider pointing a small desk fan at it. This is the #1 thing you can do to prevent a thermal-related crash.
Energy Saver: Go to System Preferences > Energy Saver and make sure "Prevent computer from sleeping automatically when the display is off" is checked. You can let the display sleep, but not the computer.
Patience: Your Mac has a mobile-class CPU. A single 1-hour 1080p episode could take 1-2 hours to encode. An entire library will take a very long time. Let it run. The script is designed to be robust and will pick up where it left off if you ever need to restart the Mac (by simply running the script again).
#!/bin/bash
#################################
# USER CONFIGURATION #
#################################
# 1. The full path to your TV show library.
# Example: "/Users/yourname/Movies/TV Shows" or "/Volumes/Media/TV Shows"
TV_SHOWS_DIR="/path/to/your/tv_shows"
# 2. The full path to the preset file you exported from HandBrake.
# Example: "/Users/yourname/Documents/mytvpreset.json"
PRESET_FILE="/path/to/your/mytvpreset.json"
# 3. The new file extension for your converted files (e.g., m4v or mp4).
# This script will IGNORE files that already have this extension.
OUTPUT_EXTENSION="mp4"
# 4. A log file to record progress and errors.
LOG_FILE="${HOME}/Desktop/handbrake_conversion.log"
#################################
# END OF CONFIGURATION #
#################################
# --- Script starts here, no need to edit below ---
echo "Starting TV Show Conversion Process at $(date)" | tee -a "$LOG_FILE"
echo "----------------------------------------------------" | tee -a "$LOG_FILE"
echo "Source Directory: $TV_SHOWS_DIR" | tee -a "$LOG_FILE"
echo "Preset File: $PRESET_FILE" | tee -a "$LOG_FILE"
echo "Log File: $LOG_FILE" | tee -a "$LOG_FILE"
echo "----------------------------------------------------" | tee -a "$LOG_FILE"
# Find all video files but exclude files with the target extension.
# Handles files with spaces or special characters correctly.
find "$TV_SHOWS_DIR" -type f \
-not -name "*.$OUTPUT_EXTENSION" \
-not -name ".*" \
-not -name "*.nfo" \
-not -name "*.jpg" \
-not -name "*.png" \
-print0 | while IFS= read -r -d '' source_file; do
echo " " | tee -a "$LOG_FILE"
echo "Found file: $source_file" | tee -a "$LOG_FILE"
# Define output filename
dir_name=$(dirname "$source_file")
base_name=$(basename "$source_file")
file_name_no_ext="${base_name%.*}"
output_file="${dir_name}/${file_name_no_ext}.${OUTPUT_EXTENSION}"
echo "Processing $(date): $base_name" | tee -a "$LOG_FILE"
# Use 'nice' to run HandBrake at a low CPU priority.
# This prevents it from hogging all resources and crashing your Mac.
nice -n 19 HandBrakeCLI --preset-import-file "$PRESET_FILE" -i "$source_file" -o "$output_file" --preset "$(basename "$PRESET_FILE" .json)" &>> "$LOG_FILE"
# Check if HandBrakeCLI was successful.
# A return code of 0 means success.
if [ $? -eq 0 ]; then
echo "SUCCESS: Conversion of $base_name completed." | tee -a "$LOG_FILE"
echo " Replacing original file." | tee -a "$LOG_FILE"
# OPTIONAL: Add a file size check here if you want extra safety.
# For now, we assume a successful exit code is enough.
# Delete the original source file
rm "$source_file"
else
echo "ERROR: HandBrake failed to convert $base_name. See log for details." | tee -a "$LOG_FILE"
echo " Cleaning up failed output file." | tee -a "$LOG_FILE"
# Delete the failed/incomplete output file
rm "$output_file"
fi
done
echo " " | tee -a "$LOG_FILE"
echo "----------------------------------------------------" | tee -a "$LOG_FILE"
echo "Conversion script finished at $(date)." | tee -a "$LOG_FILE"