Advertisement
sebbu

remove epub watermark

Nov 25th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. #!/bin/bash
  2. echo 1/7
  3. read
  4. #rename to zip
  5. for fic in *.epub;
  6. do
  7.     mv "$fic" "${fic}.zip"
  8. done
  9. #
  10. echo 2/7
  11. read
  12. #unzip
  13. for fic in *.zip;
  14. do
  15.     dir=${fic%%.zip}
  16.     mkdir "$dir"
  17.     cd "$dir"
  18.     unzip ../$fic
  19.     cd ..
  20. done
  21. #
  22. echo 3/7
  23. read
  24. #remove personnal informations
  25. for dir in */
  26. do
  27.     if [ -d ${dir}OEBPS/Text ]
  28.     then
  29.         sed -i -re 's/<!-- (\S+ )+?&lt;[a-zA-Z0-9@._-]+&gt; -->//g' ${dir}OEBPS/Text/*.*htm*
  30.     else
  31.         sed -i -re 's/<!-- (\S+ )+?&lt;[a-zA-Z0-9@._-]+&gt; -->//g' ${dir}OEBPS/*.*htm*
  32.     fi
  33. done
  34. #
  35. echo 4/7
  36. read
  37. #remove customer
  38. for ir in */
  39. do
  40.     if [ -d ${dir}OEBPS/Text ]
  41.     then
  42.         sed -i -re 's/<!-- customer [0-9]+ at [0-9-]+ [0-9:]+ [0-9:.+-]+ -->//g' ${dir}/OEBPS/Text/*.*htm*
  43.     else
  44.         sed -i -re 's/<!-- customer [0-9]+ at [0-9-]+ [0-9:]+ [0-9:.+-]+ -->//g' ${dir}/OEBPS/*.*htm*
  45.     fi
  46. done
  47. #
  48. echo 5/7
  49. read
  50. #zip
  51. for fic in *.epub/
  52. do
  53.     dir="${fic%%/}.zip"
  54.     cd "$fic"
  55.     zip -r -v ../$dir *
  56.     cd ..
  57. done
  58. #
  59. echo 6/7
  60. read
  61. #rename to epub
  62. rm -rf */
  63. for fic in *.zip
  64. do
  65.     mv "$fic" "${fic%%.zip}"
  66. done
  67. #
  68. echo 7/7
  69. echo "done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement