cbr2cbz.ksh 683 B

12345678910111213141516171819202122232425262728
  1. #!/bin/ksh
  2. for f in $(ls *.cbr)
  3. do
  4. # Set variables
  5. FILE="$f"
  6. DIR=$(echo "$FILE" | awk -F . '{print $1}')
  7. echo Extracting "$FILE" to "$DIR" ...
  8. # Create extract directory
  9. mkdir "$DIR"
  10. echo Created temporal directory "$DIR"
  11. # Extract file
  12. #7z x -o""$DIR"" ./""$FILE""
  13. unrar x -y "$FILE" "$DIR"
  14. echo Extracted "$FILE" to "$DIR"
  15. # Clean directory
  16. detox -rv "$DIR"
  17. find . -type f -name 'Thumbs.db' -exec rm {} +
  18. echo Cleaned temporal directory
  19. # Create cbz file
  20. zip -r "$DIR".cbz "$DIR"
  21. echo Created "$FILE".cbz file
  22. # Remove temporal directory
  23. rm -r "$DIR"
  24. echo Removed temporal directory "$DIR"
  25. #Remove this line if you want to remove cbr file
  26. #rm ""$FILE""
  27. done