Un bot qui récupère une image random en local et la publie
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
657 B

  1. #!/bin/bash
  2. function generate_random_char {
  3. echo $( dd if=/dev/urandom bs=16 count=1|base64) > /tmp/rename_all_image
  4. cp /tmp/rename_all_image /tmp/rename_all_image.back
  5. sed -ie 's/[!@#\+\/$%^&*()=]//g' /tmp/rename_all_image.back
  6. NEW_FILENAME=$(cat /tmp/rename_all_image.back)
  7. EXTENSION=$(echo $img | cut -f 2 -d '.')
  8. echo $NEW_FILENAME"."$EXTENSION
  9. }
  10. function move_file {
  11. NEW_FILE=$(generate_random_char)
  12. filepath=$2
  13. IMG=$1
  14. #echo $filepath"/"$NEW_FILE
  15. if [ ! -f $filepath"/"$NEW_FILE ]; then
  16. #mv $IMG $NEW_FILE
  17. mv $IMG $filepath"/"$NEW_FILE
  18. else
  19. move_file $IMG
  20. fi
  21. }
  22. for img in `ls $1/*`; do
  23. filepath=$1
  24. move_file $img $filepath
  25. done