Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-20-2019, 10:25 AM   #1
TheArtfulDodger
Zealot
TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.
 
TheArtfulDodger's Avatar
 
Posts: 144
Karma: 155110
Join Date: Nov 2010
Location: Ashford, Kent, England
Device: Kobo Clara, Kobo Touch, Kindle, Nook Touch
Question Problems Starting Calibre with command-Line Arguments from Batch File

Hello, All:

I am trying to execute Calibre from a batch file so that I can use a command-line argument "--with-library <library name>". Here's my one-line batch file (StartCalibre.bat):

"Calibre Portable\calibre-portable" --with-library "My Main Calibre Library"

and the file structure:

Q:
|
+-- File: StartCalibre.bat
|
+-- Directory: Calibre Portable
| |
| +-- File Calibre-portable.exe
| +-- Directory Calibre Settings
| +-- Directory Calibre
| +-- Directory Calibre Library
|
+-- Directory: My Main Calibre Library
| |
| +-- Directory Book1
| |
| +-- Directory Bookn
|
+-- Directory: Other Libraries

Every time I execute this batch file in Command Prompt I get a Python function terminated unexpectedly [Error 5] Access is denied (Error Code: 1). If I execute it from an Admin Command Prompt, Calibre starts but ignores the --with-library part of the instruction.

Ultimately, I want to create a shortcut to the batch file and execute Calibre that way. When I attempt this ordinarily I get the Python error; when I execute it as admin, it simply does nothing!

I would appreciate any information any guidance any one could provide!

Sparky
TheArtfulDodger is offline   Reply With Quote
Old 04-20-2019, 10:53 AM   #2
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
I don't think calibre-portable.exe supports command line arguments.

Two options.
  1. You can create a symlink of "My Main Calibre Library" inside the "Calibre Portable" directory. Calibre Portable knows how to "portabilize" those
  2. Do the entire "portabilization" in a batch file. You can use "\Calibre Portable\Calibre\resources\calibre-portable.bat" for reference.
ilovejedd is offline   Reply With Quote
Advert
Old 04-20-2019, 01:31 PM   #3
TheArtfulDodger
Zealot
TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.
 
TheArtfulDodger's Avatar
 
Posts: 144
Karma: 155110
Join Date: Nov 2010
Location: Ashford, Kent, England
Device: Kobo Clara, Kobo Touch, Kindle, Nook Touch
Question A Bit of Clarification, Please

Hello, ilovejedd:

Thanks for the reply - regarding your second suggestion: Before I go through all of the code, does this mean "use Normal Calibre" and make it think it's portable or does one use this on Calibre Portable?

Sparky
TheArtfulDodger is offline   Reply With Quote
Old 04-20-2019, 04:43 PM   #4
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Once upon a time, Calibre Portable did not exist so people created and used the batch file to make normal Calibre portable. You can use the batch file with Calibre Portable's directory structure, though, with some minor modifications (need to fix the paths).

The folder "\Calibre Portable\Calibre" already contains the normal 32-bit Windows Calibre install. It's calibre-portable.exe that handles all the portabilization.
ilovejedd is offline   Reply With Quote
Old 04-20-2019, 05:19 PM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,681
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by ilovejedd View Post
I don't think calibre-portable.exe supports command line arguments.


IIRC Calibre portable will start with the last library used.

Quote:
Originally Posted by ilovejedd View Post
  1. You can create a symlink of "My Main Calibre Library" inside the "Calibre Portable" directory. Calibre Portable knows how to "portabilize" those
Not sure what you mean by "portabilize", the OS/File system (Windows/NTFS, MacOS/HFS+ or Linux/ExtN) does the work of resolving symlinks it to physical locations. If the symlink is 'in' the calibre portable directory, that's all calibre knows, when it opens the folder symlink it sees a metadata.db, which is all it cares about.

BR

Last edited by BetterRed; 04-20-2019 at 05:27 PM.
BetterRed is offline   Reply With Quote
Advert
Old 04-20-2019, 06:29 PM   #6
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Quote:
Originally Posted by BetterRed View Post
Not sure what you mean by "portabilize", the OS/File system (Windows/NTFS, MacOS/HFS+ or Linux/ExtN) does the work of resolving symlinks it to physical locations. If the symlink is 'in' the calibre portable directory, that's all calibre knows, when it opens the folder symlink it sees a metadata.db, which is all it cares about.
What I meant was calibre-portable.exe knows how to resolve library paths inside the "\Calibre Portable\" top level directory in case the folder is moved or the drive letter changes.

For example you have:
Quote:
Q:
|
+-- File: StartCalibre.bat
|
+-- Directory: Calibre Portable
| |
| +-- File Calibre-portable.exe
| +-- Directory Calibre Settings
| +-- Directory Calibre
| +-- Directory Calibre Library
| +-- SymLink: My Main Calibre Library
| +-- SymLinks: Other Libraries
|
+-- Directory: My Main Calibre Library
|
+-- Directory: Other Libraries
and it changes to:
Quote:
X:
|
+-- File: StartCalibre.bat
|
+-- Directory: Calibre Portable
| |
| +-- File Calibre-portable.exe
| +-- Directory Calibre Settings
| +-- Directory Calibre
| +-- Directory Calibre Library
| +-- SymLink: My Main Calibre Library
| +-- SymLinks: Other Libraries
|
+-- Directory: My Main Calibre Library
|
+-- Directory: Other Libraries
calibre-portable.exe would realize that "Q:\Calibre Portable\My Main Calibre Library" has moved to "X:\Calibre Portable\My Main Calibre Library". Meanwhile, it would be unable to find "X:\My Main Calibre Library" directly.
ilovejedd is offline   Reply With Quote
Old 04-20-2019, 08:20 PM   #7
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,681
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@TheArtfulDodger - you might want to have a look into the following thread, if you haven't already ==>> Passing tray cmd line arguments to Calibre PA

BR
BetterRed is offline   Reply With Quote
Old 04-20-2019, 08:29 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,681
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by ilovejedd View Post
What I meant was calibre-portable.exe knows how to resolve library paths inside the "\Calibre Portable\" top level directory in case the folder is moved or the drive letter changes.

For example you have:


and it changes to:


calibre-portable.exe would realize that "Q:\Calibre Portable\My Main Calibre Library" has moved to "X:\Calibre Portable\My Main Calibre Library". Meanwhile, it would be unable to find "X:\My Main Calibre Library" directly.
Sorry, with respect to library locations Calibre Portable knows nothing about X: or Q: by definition libraries (or symlinks thereto) must be in the directory into which Calibre Portable is installed. If that directory happens to land on a different drive letter so be it, calibre wont care because it's all relative

And it is the OS/File system that would be unable to find a symlink target, not calibre.

You get a "No library found" message if a physical library disappears, or if a library symlink itself disappears, or if a library symlink target disappears. A feature of symlinks is that the vast majority of applications don't need to be aware that such a thing even exists.

BR
BetterRed is offline   Reply With Quote
Old 04-20-2019, 11:16 PM   #9
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Quote:
Originally Posted by BetterRed View Post
Sorry, with respect to library locations Calibre Portable knows nothing about X: or Q: by definition libraries (or symlinks thereto) must be in the directory into which Calibre Portable is installed. If that directory happens to land on a different drive letter so be it, calibre wont care because it's all relative
That's what I was trying to say. calibre-portable can resolve library paths in the top level Calibre Portable folder/same folder as calibre-portable.exe. I'm not saying that it's Calibre that does the resolving of the symlinks at all.

To make it a bit clearer, assuming you've added these three libraries in the following locations to Calibre Portable: Calibre Library, Calibre Library 2 and My Main Calibre Library
Quote:
Q:
|
+-- Directory: Calibre Portable
| |
| +-- File Calibre-portable.exe
| +-- Directory Calibre Settings
| +-- Directory Calibre
| +-- Directory Calibre Library
| +-- SymLink: Calibre Library 2 (symlink to "../My Main Calibre Library")
|
+-- Directory: My Main Calibre Library
and the location changes to this:
Quote:
X:
|
+-- Directory: Calibre Portable
| |
| +-- File Calibre-portable.exe
| +-- Directory Calibre Settings
| +-- Directory Calibre
| +-- Directory Calibre Library
| +-- SymLink: Calibre Library 2 (symlink to "../My Main Calibre Library")
|
+-- Directory: My Main Calibre Library
calibre-portable can find both Calibre Library and Calibre Library 2 but it won't be able to find My Main Calibre Library directly.


Mind, calibre-portable kinda does know about Q: and X:. The settings store absolute library paths but if the path doesn't exist, as long as the library is in the top level Calibre Portable directory (same location as calibre-portable.exe), calibre-portable can fix the path.

I've encountered occasions where where if the original absolute path still exists, it will open that one instead of the copy in the new location. e.g. If you mirror C:\Calibre Portable to Z:\Calibre Portable and run Z:\Calibre Portable\calibre-portable.exe without deleting the original folder in C:, the last opened library is usually resolved (Z: copy) but if you switch to other libraries, it would open the C: copy.
ilovejedd is offline   Reply With Quote
Old 04-21-2019, 10:51 AM   #10
TheArtfulDodger
Zealot
TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.TheArtfulDodger can grok the meaning of the universe.
 
TheArtfulDodger's Avatar
 
Posts: 144
Karma: 155110
Join Date: Nov 2010
Location: Ashford, Kent, England
Device: Kobo Clara, Kobo Touch, Kindle, Nook Touch
Smile A Watershed Moment!

Hello, All:

I wanted to thank all of you for the help you provided! It took me a while but finally I took the time to learn about SymLinks (I'd never heard of them until ilovejedd mentioned them above - and I've worked with Windows for a long time - in fact I can remember (just) Windows 3.1!) and they are magic even though they are quite simple once they are understood!

I must add that I had heard of shortcuts and I use them quite a bit!

Anyway, I completely misunderstood the statement that, for Calibre to 'remember' the last library used, the library had to be in the Calibre Portable folder. From the above you can see that all of the libraries reside on the same drive and I thought that was enough. Now, however, thanks to SymLinks, they do all reside in the right place.

Again, many thanks for the magic help!

Sparky
TheArtfulDodger is offline   Reply With Quote
Old 04-21-2019, 05:11 PM   #11
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,681
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
IIRC MS symbolic links first surfaced in NT 4, but for some reason MS hid them in XP (there were 3rd party shims that would 'unhide' them), they were exposed in Vista.

Data General and Digital Equipment proprietary OSs supported symlinks in the early 1970s.

BR
BetterRed is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing tray cmd line arguments to Calibre PA stisev Calibre 5 02-24-2019 07:29 AM
command line batch to change title etc. boell Library Management 6 10-14-2012 06:42 PM
[Old Thread] Calibre Command line and .bat file stratman Calibre 15 01-10-2012 05:38 PM
Command Line Batch Adding of Epubs nkormanik Calibre 6 10-19-2010 08:04 AM
adding books via command line in msdos batch FlaKate Calibre 1 12-25-2009 01:12 AM


All times are GMT -4. The time now is 11:26 PM.


MobileRead.com is a privately owned, operated and funded community.