Skip to content

Instantly share code, notes, and snippets.

@x512
Last active November 28, 2024 20:21
Show Gist options
  • Select an option

  • Save x512/de36604139f39c4c594d2869ff81b148 to your computer and use it in GitHub Desktop.

Select an option

Save x512/de36604139f39c4c594d2869ff81b148 to your computer and use it in GitHub Desktop.
Copy a VIDEO_TS folder, verify it against the original, and eject the disc. This was for macOS 11.2 I think.
# Find the first media drive (CD or DVD)
dvd_path=$(mount | grep 'media/cdrom' | awk '{print $3}' | head -n 1)
# Copy the VIDEO_TS folder to the desktop
cp -r "$dvd_path/VIDEO_TS" ~/Desktop
# Generate checksums for the original and copied folders
md5 "$dvd_path/VIDEO_TS" > original_checksum.txt
md5 ~/Desktop/VIDEO_TS > copied_checksum.txt
# Compare the original and copied checksums
if diff original_checksum.txt copied_checksum.txt; then
# If the checksums match, remove the checksum files
rm original_checksum.txt copied_checksum.txt
else
# If the checksums do not match, print an error message
echo "ERROR: The copied VIDEO_TS folder is not identical to the original."
fi
# Eject the disc
diskutil eject "$dvd_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment