SHARE
TWEET

baloo-tag-search-copy.sh

TringaliLuca Mar 31st, 2018 (edited) 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. folder="~/Immagini"
  4. tag="speleologia"
  5. destination="/tmp"
  6.  
  7. #tmpfile="/tmp/result.txt"
  8. tmpfile=$(tempfile)
  9. baloosearch -d $folder "tags:$tag" > $tmpfile
  10.  
  11.  
  12. while read line
  13. do
  14. if [ -f "$line" ]; then
  15.  
  16. destname="$destination/${line##*/}"
  17.  
  18. n=1
  19. while [ -f "$destname" ]
  20. do
  21. if cmp -s "$line" "$destname" ; then
  22. break
  23. else
  24. let "n += 1"
  25. tmpname=${line##*/}
  26. destname="$destination/${tmpname%.*}_$n.${tmpname##*.}"
  27. fi
  28. done
  29.  
  30. cp "$line" "$destname"
  31. echo "$destname OK"
  32.  
  33. fi
  34. done <$tmpfile
  35.  
  36. rm $tmpfile
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top