View Single Post
Old 01-15-2016, 03:22 PM   #11
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,463
Karma: 10684861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by kensmosis View Post
@kacir Thanks for the detailed and informative reply! From both answers, it seems pretty clear that I will have to script things. I had considered your approach as one of two if calibre couldn't do this natively. Perhaps you would be kind enough to advise me which would be better. I have about 10000 files, so I'll probably write a Perl script to manage the process either way.
You do not HAVE to write the script nowadays.
I have just tested krename and you can very easily do the rename from its GUI.
Just select files and set Filename to Custom name from dropbox and click on the lightbulb button and build following expression [creationdate;yyyy.MM.dd]---$
Depending on circumstances I personally would either use krename or write a Gvim script that would then write shell script from an ls -l > something.txt list.
Quote:
Originally Posted by kensmosis View Post
1. As you say, embed the date in the filename. I appreciate the guidance, and don't see this as being a problem. This approach has the advantage of being easy and unintrusive regarding the metadata.db itself. However, it seems a bit unnatural because the files themselves (the ones managed by calibre) would still lose their timestamps. If for some reason I need that info down the road, I'll have to reconstruct it from the db or hope I have an original copy of the files floating about.
I personally have used the modification of the filename as a preparation for adding to Calibre quite a few times and I see many advantages.
The name of the file remains unchanged in Calibre, so it will preserve the info about the original creation date.
Also, it is Not A Good Idea (TM) to work with files behind Calibre back. Use Calibre itself to access the files inside and treat filesystem as a black box. There are many, MANY threads discussing this. The files are user readable and this is great advantage in the case of disaster or something - you can salvage the remains of the library even if it is heavily damaged.

I always use simple Drag & Drop to add numerous files to Calibre to add files.
Quote:
Originally Posted by kensmosis View Post

2. Alterately, I could edit the db. I would add the files to calibre as is, and then do two things (to clarify, the 2nd approach involves doing both):
(a) Run a SQL query to modify the "Date/timestamp" and/or "Published/pubdate" fields (or just add custom fields for the filesystem ctime and mtime and populate those). I also can directly modify the "modified" date by this approach regardless of its ro status in calibre.
(b) Using "touch -r $orig_file $calibre_copy_of_file", change the dates of the files themselves under calibre's management.

This 2nd approach requires a little finesse because my files are in multiple subdirectories (I add them using the "include subdirectories" option) -- so there may be recycled filenames. I probably would have to use an md5 checksum to match files instead, but this isn't a big deal. While this approach seems a bit more intrusive and involved, it has the advantage that -- if done right -- in the end the world will look to calibre just as it does to the filesystem itself. The files will seem as if they had been added one by one at the time of their (filesystem) creation, and last modified at the time of their last filesystem modification.
I personally prefer solution #1. As I said it is not a good idea to do ANYTHING with files once they are inside the library behind Calibre's back ;-)
kacir is offline   Reply With Quote