Advertisement
fant0men

Messing around with my FLAC library

Aug 27th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. Find misplaced log files in my music library:
  2.  
  3. find . -type d -name "*" | while read dir; do list=$(ls -1 "${dir}" 2>/dev/null); n=$(echo "${list}" | wc -l | tr -d "[:space:]"); log=$(echo "${list}" | grep ".log$"); if [[ $n -lt 4 && ! -z $log ]]; then echo "${log} in ${dir}"; fi; done
  4.  
  5.  
  6.  
  7. Find empty directories:
  8.  
  9. find . -type d -name "*" | while read dir; do n=$(ls -1 "${dir}" 2>/dev/null | wc -l); if [[ $n -eq 0 ]]; then echo "${dir}"; fi; done
  10.  
  11.  
  12.  
  13. Compare log files:
  14.  
  15. find . -name "*.log" | while read log; do md5sum -b "$log" | cut -d'*' -f1; done | sort > ~/Desktop/md5sum_library.txt
  16.  
  17. find . -name "*.log" | while read log; do md5sum -b "$log" | cut -d'*' -f1; done | sort > ~/Desktop/md5sum_diff.txt
  18.  
  19. cat md5sum_diff.txt | while read md5; do grep "$md5" md5sum_library.txt && echo "$md5" >> md5sum_remove.txt; done
  20.  
  21. find . -name "*.log" | while read log; do md5=$(md5sum -b "$log" | cut -d'*' -f1 | tr -d "[:space:]"); grep "$md5" ~/Desktop/md5sum_remove.txt && rm "$log"; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement