Delete files following a pattern
find . -name '*.orig' #-delete
Source
rsync excluding files
rsync -av --exclude 'filename' source/ destination/
Source
EXIF-based commands
Rename and move files based on year-month taken
exiftool "-Directory<%d\sorted\$DateTimeOriginal" -d "%Y-%m" "F:\pictures\Temp Import 2020"
Source
Rename based on date-time taken
exiftool -m -P -d %Y%m%d_%H%M%S '-filename<${DateTimeOriginal}_%f.%e' *
Move files and add index if name already exists
mv --backup=numbered bar/* foo/* -t blah
Source
Resize images
convert input.jpg -resize 50% output.jpg
Resize a PDF
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Source
Git clean local branches
function gitcleanlocalbranches() {
git fetch -p && for branch in `git branch -vv | grep ':gone]' | awk '{print $1}'`; do git branch -D $branch; done
}