Advertisement
den4ik2003

Untitled

Feb 22nd, 2023
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. while [ -n "$1" ]
  4. do
  5. case "$1" in
  6.     --input_folder)
  7.         inp_fold=$2
  8.         ;;
  9.     --extension)
  10.         ext=$2
  11.         ;;
  12.     --backup_folder)
  13.         back_fold=$2
  14.         ;;
  15.     --backup_archive_name)
  16.         arch_name=$2
  17.         ;;
  18. esac
  19. shift
  20. shift
  21. done
  22.  
  23. mkdir $back_fold
  24. cmp=1
  25. for file in $(find "$inp_fold" -name "*.$ext")
  26. do
  27.     file_name=$(basename $file)
  28.     cp $file "$back_fold/($cmp)$file_name"
  29.     (( cmp++ ))
  30. done
  31. tar -Pczf $arch_name $back_fold
  32. echo done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement