This guide documents two bash scripts designed to automate the processing of movie releases (e.g., from Usenet or scene releases) that are stored in .rar
archives and optionally include .sfv
verification files.
Choose between two modes:
ffmpeg
to re-encode the audio track (e.g., to AAC for better compatibility).UPLOAD
and RETAIL-NEW
.
Both scripts require the following tools to be installed:
unrar
– For extracting RAR filescksfv
– For verifying file integrity via .sfvffmpeg
– (Only for the transcoding script)sudo apt update
sudo apt install unrar cksfv ffmpeg
unrar-moviez-transcode.sh
(with ffmpeg)This script performs the following steps:
UPLOAD
directory.sfv
file and verifies the archive integrity.mkv
file using unrar
ffmpeg
(video is copied without re-encoding)RETAIL-NEW
directory#!/bin/bash
# === Configuration ===
bindir="/home/VOD"
lockfile="$bindir/.lockfile_unrar"
upload="$bindir/UPLOAD"
files="$bindir/RETAIL-NEW"
# === Dependency check ===
for cmd in cksfv unrar ffmpeg; do
if ! command -v "$cmd" &>/dev/null; then
echo "Error: $cmd is not installed."
exit 1
fi
done
# === Prevent parallel execution ===
[ -f "$lockfile" ] && echo "Script already running." && exit 1
touch "$lockfile"
for dir in "$upload"/*/; do
[ -d "$dir" ] || continue
echo "[*] Processing $dir"
cd "$dir"
if ls *.sfv 1> /dev/null 2>&1; then
echo "Verifying archive..."
cksfv -q *.sfv || continue
fi
unrar e -y *.rar
mkv=$(ls *.mkv | head -n1)
if [ -n "$mkv" ]; then
out="$files/$(basename "$dir").mkv"
echo "Transcoding audio..."
ffmpeg -i "$mkv" -c:v copy -c:a aac -b:a 160k "$out"
echo "[✓] Done: $out"
fi
rm -rf "$dir"
done
rm -f "$lockfile"
unrar-moviez-copy.sh
(copy only)Same as above, but without transcoding. It simply extracts and moves the first .mkv
file found.
#!/bin/bash
# === Configuration ===
bindir="/home/VOD"
lockfile="$bindir/.lockfile_unrar"
upload="$bindir/UPLOAD"
files="$bindir/RETAIL-NEW"
# === Dependency check ===
for cmd in cksfv unrar; do
if ! command -v "$cmd" &>/dev/null; then
echo "Error: $cmd is not installed."
exit 1
fi
done
# === Prevent parallel execution ===
[ -f "$lockfile" ] && echo "Script already running." && exit 1
touch "$lockfile"
for dir in "$upload"/*/; do
[ -d "$dir" ] || continue
echo "[*] Processing $dir"
cd "$dir"
if ls *.sfv 1> /dev/null 2>&1; then
echo "Verifying archive..."
cksfv -q *.sfv || continue
fi
unrar e -y *.rar
mkv=$(ls *.mkv | head -n1)
if [ -n "$mkv" ]; then
mv "$mkv" "$files/$(basename "$dir").mkv"
echo "[✓] Copied: $files/$(basename "$dir").mkv"
fi
rm -rf "$dir"
done
rm -f "$lockfile"
*/15 * * * * /home/VOD/unrar-moviez-transcode.sh >/dev/null 2>&1
UPLOAD
and RETAIL-NEW
exist and are writable.