# Regex Find Playlist Files
find . -type f -regextype posix-extended -regex ".*.(m3u|pls)$"

# Notes on Name:
-name pattern
              Base of  file  name  (the  path  with  the  leading  directories
              removed)  matches  shell  pattern  pattern.   The metacharacters
              (`*', `?', and `[]') match a `.' at the start of the  base  name
              (this is a change in findutils-4.2.2; see section STANDARDS CON‐
              FORMANCE below).  To ignore a directory and the files under  it,
              use  -prune; see an example in the description of -path.  Braces
              are not recognised as being special, despite the fact that  some
              shells  including  Bash  imbue  braces with a special meaning in
              shell patterns.  The filename matching is performed with the use
              of  the  fnmatch(3)  library function.   Don't forget to enclose
              the pattern in quotes in order to protect it from  expansion  by
              the shell.
# Exclude all files with ".01_" and ".15_"; find only files older than 30 days
find ${BACKUP_DIR} ! -name '*.01_*' ! -name '*.15_*' -mtime +30 -type f -delete -printf "Delete: %f\n"
# Minimum Depth
find . -mindepth 2 -type d -empty

# Find empty files
find . -mindepth 2 -type f -empty

# Print all Movie Folders that are empty
find . -mindepth 1 -maxdepth 1 -type d -empty -printf "%f\n"
# unrar each part1.rar file
find . -name "*.part1.rar" -exec unrar x {} \;
find . -name "*.rar" -execdir unrar x {} \;

# Scene Extraction:
find . -type f -name '*.rar' -execdir unrar x {} \;
find . -type f -name '*.rar' -execdir sh -c 'rm "${0%%.rar}".r??' {} \;
# Files older than 180d
cd /mnt/xenon/HF_WIP/ && find . -mtime 180
# Meta files
# TODO: Add Size to reduce risk of deleting important data
find . -name 'Thumbs.db' -type f -delete
find . -name '*.DS_Store' -type f -delete
find . -name '._*' -type f -delete

# Meta directories
find . -name '*.' -type d -delete

# Empty directories
find . -type d -empty -delete
# Delete OS-Metadata
find /mnt/video05 \( -name ".DS_Store" -or -name ".AppleDouble" -or -name ".Trashes" -or -name "._*" -or -name ".TemporaryItems" \) -delete
find /mnt/drive -name ".AppleDouble" -delete

# Safer Version of Metadata deletion:
find /mnt/video0{1,5} \( -name ".DS_Store" -or -name ".AppleDouble" -or -name ".Trashes" -or -name "._*" -or -name ".TemporaryItems" \) -size -2m -type f -delete
find /mnt/video0{1,5} -type d -empty -delete

-mtime +60 means you are looking for a file modified >=60 days ago. -mtime -60 means less than 60 days. -mtime 60 If you skip + or – it means exactly 60 days.

# Find 0 Byte Files in last 30 days (by modtime)
find . -mtime 30 -type f -size 0 -print
# Find 0 Byte Files in last 30 days (by accesstime)
find . -atime 30 -type f -size 0 -print
# Anytime
find "$project" -type f -size 0 -print
# Looped
for project in *
echo "$project"
find "$project" -type f -iname "*.*" -size 0 -print | wc -l
# Find all files older than 7 days and delete
# => HF_SCAN example
find /path/to/folder/ -mtime +7 -type f -delete
# Find Sample Folders and delete
find . -type d -name "Sample" -exec echo "{}" \;
set -e

find /mnt/archive/movies -type d -name '_archive' -print -execdir bash -c "cd {} && ls -l" \; # cd to dir and list files

# cd to _archive folder, move content to parent (include dotfiles)
find /mnt/archive/movies \
-type d \
-name '_archive' \
-print \
-execdir bash -c "shopt -s dotglob; cd {} && mv * ../" \;

find /mnt/archive/movies -type d -empty -delete

cleanup disks (cronjob)

In some cases you can't always enforce the clients to behave nicely (thanks macOS!) ⥊ In that case we need to do some server-site cleanings. Here we delete all the junk metadata the clients leave on our beloved NAS System. I'd say if you set them as a @daily crontask, that should be enough.

find /mnt/video0{1,5} \( -name ".DS_Store" -or -name ".AppleDouble" -or -name ".Trashes" -or -name "._*" -or -name ".TemporaryItems" \) -size -2m -type f -delete
# Delete empty directores
find /mnt/video0{1,5} -type d -empty -delete
# delete empty files
find /mnt/video0{1,5} -type f -empty -delete