find-and-drag-drop.sh 487 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. display_help(){
  4. echo "Usage: ${0##*/} -iname [pattern]"
  5. exit 2
  6. }
  7. error() {
  8. echo "$0: $*" >&2
  9. exit 1
  10. }
  11. [[ $# -lt 1 ]] && display_help
  12. date=$(date +'%F_%H%M%S')
  13. pattern="$@"
  14. DIR="/tmp/drag-drop_${pattern}_${date}/"
  15. mkdir -p "$DIR"
  16. find "$PWD" -type f -iname "$pattern" -print0 -exec ln -s {} "$DIR" \;
  17. # find $PWD -type f -name "*.docx" -print0 | xargs -0 -I{} -- echo qwe; ln -s {} /tmp/qwerty
  18. nautilus "$DIR"