Debian Codegraph @

resources/calibre-portable.bat

raw
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
44
45 REM -------------------------------------
46 REM Set up calibre config folder
47 REM
48 REM This is where user specific settings
49 REM are stored.
50 REM -------------------------------------
51
52 IF EXIST CalibreConfig (
53 SET CALIBRE_CONFIG_DIRECTORY=%cd%\CalibreConfig
54 ECHO CONFIG FILES: %cd%\CalibreConfig
55 )
56
57
58 REM --------------------------------------------------------------
59 REM Specify location of ebooks
60 REM
61 REM Location where book files are located
62 REM Either set explicit path, or if running from a USB stick
63 REM a relative path can be used to avoid need to know the
64 REM drive letter of the USB stick.
65 REM
66 REM Comment out any of the following that are not to be used
67 REM (although leaving them in does not really matter)
68 REM --------------------------------------------------------------
69
70 IF EXIST U:\eBooks\CalibreLibrary (
71 SET CALIBRE_LIBRARY_DIRECTORY=U:\eBOOKS\CalibreLibrary
72 ECHO LIBRARY FILES: U:\eBOOKS\CalibreLibrary
73 )
74 IF EXIST CalibreLibrary (
75 SET CALIBRE_LIBRARY_DIRECTORY=%cd%\CalibreLibrary
76 ECHO LIBRARY FILES: %cd%\CalibreLibrary
77 )
78
79
80 REM --------------------------------------------------------------
81 REM Specify Location of metadata database (optional)
82 REM
83 REM Location where the metadata.db file is located. If not set
84 REM the same location as book files will be assumed. This.
85 REM option is typically set to get better performance when the
86 REM library is on a (slow) network drive. Putting the metadata.db
87 REM file locally then makes gives a big performance improvement.
88 REM
89 REM NOTE. If you use this option, then the ability to switch
90 REM libraries within calibre will be disabled. Therefore
91 REM you do not want to set it if the metadata.db file
92 REM is at the same location as the book files.
93 REM
94 REM Another point to watch is that plugins can cause problems
95 REM as they often store absolute path information
96 REM --------------------------------------------------------------
97
98 IF EXIST %cd%\CalibreMetadata\metadata.db (
99 IF NOT "%CALIBRE_LIBRARY_DIRECTORY%" == "%cd%\CalibreMetadata" (
100 SET CALIBRE_OVERRIDE_DATABASE_PATH=%cd%\CalibreMetadata\metadata.db
101 ECHO DATABASE: %cd%\CalibreMetadata\metadata.db
102 ECHO '
103 ECHO ***CAUTION*** Library switching will be disabled
104 ECHO '
105 )
106 )
107
108 REM --------------------------------------------------------------
109 REM Specify location of source (optional)
110 REM
111 REM It is easy to run calibre from source
112 REM Just set the environment variable to where the source is located
113 REM When running from source the GUI will have a '*' after the version.
114 REM number that is displayed at the bottom of the calibre main screen.
115 REM
116 REM More information on setting up a development environment can
117 REM be found at:
118 REM https://manual.calibre-ebook.com/develop.html#develop
119 REM --------------------------------------------------------------
120
121 IF EXIST CalibreSource\src (
122 SET CALIBRE_DEVELOP_FROM=%cd%\CalibreSource\src
123 ECHO SOURCE FILES: %cd%\CalibreSource\src
124 ) ELSE (
125 ECHO SOURCE FILES: *** Not being Used ***
126 )
127
128
129 REM --------------------------------------------------------------
130 REM Specify location of calibre Windows binaries (optional)
131 REM
132 REM To avoid needing calibre to be set in the search path, ensure
133 REM that calibre program files is current directory when starting.
134 REM The following test falls back to using search path .
135 REM This folder can be populated by copying the Calibre2 folder from
136 REM an existing installation or by installing direct to here.
137 REM
138 REM NOTE. Do not try and put both Windows and Linux binaries into
139 REM same folder as this can cause problems.
140 REM --------------------------------------------------------------
141
142 IF EXIST %cd%\Calibre2 (
143 CD %cd%\Calibre2
144 ECHO PROGRAM FILES: %cd%
145 ) ELSE (
146 ECHO PROGRAM FILES: *** Use System search PATH ***
147 )
148
149
150 REM --------------------------------------------------------------
151 REM Location of calibre temporary files (optional)
152 REM
153 REM calibre creates a lot of temporary files while running
154 REM In theory these are removed when calibre finishes, but
155 REM in practise files can be left behind (particularly if
156 REM any errors occur). Using this option allows some
157 REM explicit clean-up of these files.
158 REM If not set calibre uses the normal system TEMP location
159 REM --------------------------------------------------------------
160
161 SET CALIBRE_TEMP_DIR=%TEMP%\CALIBRE_TEMP
162 ECHO TEMPORARY FILES: %CALIBRE_TEMP_DIR%
163
164 IF EXIST "%CALIBRE_TEMP_DIR%" RMDIR /s /q "%CALIBRE_TEMP_DIR%"
165 MKDIR "%CALIBRE_TEMP_DIR%"
166 REM set the following for any components that do
167 REM not obey the CALIBRE_TEMP_DIR setting
168 SET TMP=%CALIBRE_TEMP_DIR%
169 SET TEMP=%CALIBRE_TEMP_DIR%
170
171
172 REM --------------------------------------------------------------
173 REM Set the interface language (optional)
174 REM
175 REM If not set calibre uses the language set in preferences
176 REM --------------------------------------------------------------
177
178 SET CALIBRE_OVERRIDE_LANG=EN
179 ECHO INTERFACE LANGUAGE: %CALIBRE_OVERRIDE_LANG%
180
181 REM ----------------------------------------------------------
182 REM The following gives a chance to check the settings before
183 REM starting calibre. It can be commented out if not wanted.
184 REM ----------------------------------------------------------
185
186 ECHO '
187 ECHO Press CTRL-C if you do not want to continue
188 PAUSE
189
190
191 REM --------------------------------------------------------
192 REM Start up the calibre program.
193 REM
194 REM The use of 'belownormal' priority helps keep the system
195 REM responsive while calibre is running. Within calibre itself
196 REM the background processes should be set to run with 'low' priority.
197
198 REM Using the START command starts up Calibre in a separate process.
199 REM If used without /WAIT option it launches calibre and continues batch file.
200 REM normally this would simply run off the end and close the Command window.
201 REM Use with /WAIT to wait until calibre completes to run a task on exit
202 REM --------------------------------------------------------
203
204 ECHO "Starting up calibre"
205 ECHO OFF
206 ECHO %cd%
207 START /belownormal calibre --with-library "%CALIBRE_LIBRARY_DIRECTORY%"