calibre-portable.bat 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. @echo OFF
  2. REM Calibre-Portable.bat
  3. REM ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
  4. REM
  5. REM Batch file to start a calibre configuration on Windows
  6. REM giving explicit control of the location of:
  7. REM - calibre program files
  8. REM - calibre library files
  9. REM - calibre config files
  10. REM - calibre metadata database
  11. REM - calibre source files
  12. REM - calibre temp files
  13. REM By setting the paths correctly it can be used to run:
  14. REM - A "portable calibre" off a USB stick.
  15. REM - A network installation with local metadata database
  16. REM (for performance) and books stored on a network share
  17. REM - A local installation using customised settings
  18. REM
  19. REM If trying to run off a USB stick then the folder structure
  20. REM shown below is recommended (relative to the location of
  21. REM this batch file). This can structure can also be used
  22. REM when running of a local hard disk if you want to get the
  23. REM level of control this batch file provides.
  24. REM - Calibre2 Location of program files
  25. REM - CalibreConfig Location of configuration files
  26. REM - CalibreLibrary Location of books and metadata
  27. REM - CalibreSource Location of calibre source files (Optional)
  28. REM
  29. REM This batch file is designed so that if you create the recommended
  30. REM folder structure then it can be used 'as is' without modification.
  31. REM
  32. REM More information on the environment variables used by calibre can
  33. REM be found at:
  34. REM https://manual.calibre-ebook.com/customize.html#environment-variables
  35. REM
  36. REM The documentation for this file in the Calibre manual can be found at:
  37. REM https://manual.calibre-ebook.com/portable.html
  38. REM
  39. REM CHANGE HISTORY
  40. REM ¬¬¬¬¬¬¬¬¬¬¬¬¬¬
  41. REM 22 Jan 2012 itimpi - Updated to keep it in line with the calibre-portable.sh
  42. REM file for Linux systems
  43. REM -------------------------------------
  44. REM Set up calibre config folder
  45. REM
  46. REM This is where user specific settings
  47. REM are stored.
  48. REM -------------------------------------
  49. IF EXIST CalibreConfig (
  50. SET CALIBRE_CONFIG_DIRECTORY=%cd%\CalibreConfig
  51. ECHO CONFIG FILES: %cd%\CalibreConfig
  52. )
  53. REM --------------------------------------------------------------
  54. REM Specify location of ebooks
  55. REM
  56. REM Location where book files are located
  57. REM Either set explicit path, or if running from a USB stick
  58. REM a relative path can be used to avoid need to know the
  59. REM drive letter of the USB stick.
  60. REM
  61. REM Comment out any of the following that are not to be used
  62. REM (although leaving them in does not really matter)
  63. REM --------------------------------------------------------------
  64. IF EXIST U:\eBooks\CalibreLibrary (
  65. SET CALIBRE_LIBRARY_DIRECTORY=U:\eBOOKS\CalibreLibrary
  66. ECHO LIBRARY FILES: U:\eBOOKS\CalibreLibrary
  67. )
  68. IF EXIST CalibreLibrary (
  69. SET CALIBRE_LIBRARY_DIRECTORY=%cd%\CalibreLibrary
  70. ECHO LIBRARY FILES: %cd%\CalibreLibrary
  71. )
  72. REM --------------------------------------------------------------
  73. REM Specify Location of metadata database (optional)
  74. REM
  75. REM Location where the metadata.db file is located. If not set
  76. REM the same location as book files will be assumed. This.
  77. REM option is typically set to get better performance when the
  78. REM library is on a (slow) network drive. Putting the metadata.db
  79. REM file locally then makes gives a big performance improvement.
  80. REM
  81. REM NOTE. If you use this option, then the ability to switch
  82. REM libraries within calibre will be disabled. Therefore
  83. REM you do not want to set it if the metadata.db file
  84. REM is at the same location as the book files.
  85. REM
  86. REM Another point to watch is that plugins can cause problems
  87. REM as they often store absolute path information
  88. REM --------------------------------------------------------------
  89. IF EXIST %cd%\CalibreMetadata\metadata.db (
  90. IF NOT "%CALIBRE_LIBRARY_DIRECTORY%" == "%cd%\CalibreMetadata" (
  91. SET CALIBRE_OVERRIDE_DATABASE_PATH=%cd%\CalibreMetadata\metadata.db
  92. ECHO DATABASE: %cd%\CalibreMetadata\metadata.db
  93. ECHO '
  94. ECHO ***CAUTION*** Library switching will be disabled
  95. ECHO '
  96. )
  97. )
  98. REM --------------------------------------------------------------
  99. REM Specify location of source (optional)
  100. REM
  101. REM It is easy to run calibre from source
  102. REM Just set the environment variable to where the source is located
  103. REM When running from source the GUI will have a '*' after the version.
  104. REM number that is displayed at the bottom of the calibre main screen.
  105. REM
  106. REM More information on setting up a development environment can
  107. REM be found at:
  108. REM https://manual.calibre-ebook.com/develop.html#develop
  109. REM --------------------------------------------------------------
  110. IF EXIST CalibreSource\src (
  111. SET CALIBRE_DEVELOP_FROM=%cd%\CalibreSource\src
  112. ECHO SOURCE FILES: %cd%\CalibreSource\src
  113. ) ELSE (
  114. ECHO SOURCE FILES: *** Not being Used ***
  115. )
  116. REM --------------------------------------------------------------
  117. REM Specify location of calibre Windows binaries (optional)
  118. REM
  119. REM To avoid needing calibre to be set in the search path, ensure
  120. REM that calibre program files is current directory when starting.
  121. REM The following test falls back to using search path .
  122. REM This folder can be populated by copying the Calibre2 folder from
  123. REM an existing installation or by installing direct to here.
  124. REM
  125. REM NOTE. Do not try and put both Windows and Linux binaries into
  126. REM same folder as this can cause problems.
  127. REM --------------------------------------------------------------
  128. IF EXIST %cd%\Calibre2 (
  129. CD %cd%\Calibre2
  130. ECHO PROGRAM FILES: %cd%
  131. ) ELSE (
  132. ECHO PROGRAM FILES: *** Use System search PATH ***
  133. )
  134. REM --------------------------------------------------------------
  135. REM Location of calibre temporary files (optional)
  136. REM
  137. REM calibre creates a lot of temporary files while running
  138. REM In theory these are removed when calibre finishes, but
  139. REM in practise files can be left behind (particularly if
  140. REM any errors occur). Using this option allows some
  141. REM explicit clean-up of these files.
  142. REM If not set calibre uses the normal system TEMP location
  143. REM --------------------------------------------------------------
  144. SET CALIBRE_TEMP_DIR=%TEMP%\CALIBRE_TEMP
  145. ECHO TEMPORARY FILES: %CALIBRE_TEMP_DIR%
  146. IF EXIST "%CALIBRE_TEMP_DIR%" RMDIR /s /q "%CALIBRE_TEMP_DIR%"
  147. MKDIR "%CALIBRE_TEMP_DIR%"
  148. REM set the following for any components that do
  149. REM not obey the CALIBRE_TEMP_DIR setting
  150. SET TMP=%CALIBRE_TEMP_DIR%
  151. SET TEMP=%CALIBRE_TEMP_DIR%
  152. REM --------------------------------------------------------------
  153. REM Set the interface language (optional)
  154. REM
  155. REM If not set calibre uses the language set in preferences
  156. REM --------------------------------------------------------------
  157. SET CALIBRE_OVERRIDE_LANG=EN
  158. ECHO INTERFACE LANGUAGE: %CALIBRE_OVERRIDE_LANG%
  159. REM ----------------------------------------------------------
  160. REM The following gives a chance to check the settings before
  161. REM starting calibre. It can be commented out if not wanted.
  162. REM ----------------------------------------------------------
  163. ECHO '
  164. ECHO Press CTRL-C if you do not want to continue
  165. PAUSE
  166. REM --------------------------------------------------------
  167. REM Start up the calibre program.
  168. REM
  169. REM The use of 'belownormal' priority helps keep the system
  170. REM responsive while calibre is running. Within calibre itself
  171. REM the background processes should be set to run with 'low' priority.
  172. REM Using the START command starts up Calibre in a separate process.
  173. REM If used without /WAIT option it launches calibre and continues batch file.
  174. REM normally this would simply run off the end and close the Command window.
  175. REM Use with /WAIT to wait until calibre completes to run a task on exit
  176. REM --------------------------------------------------------
  177. ECHO "Starting up calibre"
  178. ECHO OFF
  179. ECHO %cd%
  180. START /belownormal calibre --with-library "%CALIBRE_LIBRARY_DIRECTORY%"