Advertisement
TringaliLuca

baloo-tag-search-copy.sh

Mar 31st, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement