Optimize Command Line Batch Processing Using the Find Command

Find All Jpegs
find ./ -iname '*.jpg'
Find and Optimize all Jpegs
find ./ -iname '*.jpg' -exec jpegoptim -p {} \;
Create Hidden File to Track Date
touch .jpeg_crush
Create Optimization Script
nano jpeg_crush.sh
#!/bin/bash
find ./ -newer .jpeg_crush -iname '*.jpg' -exec jpegoptim -p {} \;
touch .jpeg_crush

Type control-o, control-x to exit.

Make Script Executable
chmod +x jpeg_crush.sh
Run Jpeg Crush
./jpeg_crush.sh

Stream a Mac Screen to a Raspberry Pi using FFmpeg

In this video I stream a Mac screen to a Raspberry Pi using FFmpeg. This could be used for remotely displaying a presentation. This does not transmit audio from the Mac.

Raspberry Pi (Amazon Affiliate)
US: https://amzn.to/2LpyVob
UK: https://amzn.to/2Z2inKX
CA: https://amzn.to/2y5yAUA
ES: https://amzn.to/3fSDhSS
FR: https://amzn.to/2LpurxT
IT: https://amzn.to/2T2VZNu
DE: https://amzn.to/3buHRmQ
IN: https://amzn.to/2B3PGTN

List Devices
ffmpeg -f avfoundation -list_devices true -i ""
FFmpeg Command on Mac
ffmpeg -f avfoundation -i "1" -vcodec h264_videotoolbox -realtime 1 -pix_fmt nv12 -b:v 5000k -f mpegts udp://ip_address_of_pi:1234
Command on Raspberry Pi
omxplayer --timeout 60 ip_address_of_mac:1234

Find Duplicate Files Using the Command Line on a Mac (or Linux)

In this video I use a number of different command line utilities to identify duplicate files.

Print Working Directory
pwd
Find All Files in Current Directory
find ./
Find Only Files (no directories)
find ./ -type f
Find Only Non-empty Files (no directories)
find ./ -type f -not -empty
Find Only Non-empty Files and Exclude Files in Library Directory (no directories)
find ./ -type f -not -empty -not -path './/Library/*'
Get md5sum of Find Results (Mac)
find ./ -type f -not -empty -not -path './/Library/*' -exec md5 -r {} \;
Get md5sum of Find Results (Linux)
find ./ -type f -not -empty -not -path './/Library/*' -exec md5sum {} \;

Note: use “md5 -r” on Mac and “md5sum” on Linux in any future command.

Write md5sums to File
find ./ -type f -not -empty -not -path './/Library/*' -exec md5 -r {} \; > file_list.txt
Count the Number of Lines in file_list.txt
wc -l file_list.txt
Get list of md5sums for Jpeg Files
find ./ -type f -not -empty -not -path './/Library/*' -iname '*.jpg' -exec md5 -r {} \; > file_list.txt
View first 10 Lines of a File
head -n 10 file_list.txt
View first 20 Lines of File
head -n 20 file_list.txt
Sort file_list.txt
sort file_list.txt > file_list_sort.txt
Output file_list_sort.txt to Terminal
cat file_list_sort.txt
Isolate the md5sums
cat file_list_sort.txt | cut -d ' ' -f1
Count Each md5sum
cat file_list_sort.txt | cut -d ' ' -f1 | uniq -c
Remove md5sums of Files that only have 1 Copy
cat file_list_sort.txt | cut -d ' ' -f1 | uniq -c | grep -v '^   1 '
Swap md5sum and Count
cat file_list_sort.txt | cut -d ' ' -f1 | uniq -c | grep -v '^   1 ' | awk '{ t=$1 ; $1=$2; $2=t; print }'
Sort md5sum and Count List by Hash
cat file_list_sort.txt | cut -d ' ' -f1 | uniq -c | grep -v '^   1 ' | awk '{ t=$1 ; $1=$2; $2=t; print }' | sort
Write Results to File
cat file_list_sort.txt | cut -d ' ' -f1 | uniq -c | grep -v '^   1 ' | awk '{ t=$1 ; $1=$2; $2=t; print }' | sort > file_counts.txt
Join File List to md5sum Counts
join -1 1 -2 1 file_counts.txt file_list_sort.txt
Sort Joined Results
join -1 1 -2 1 file_counts.txt file_list_sort.txt |sort -k2,2 -n -k1,1
Save Joined Results to a File
join -1 1 -2 1 file_counts.txt file_list_sort.txt |sort -k2,2 -n -k1,1 > file_dups.txt