w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to convert hundreds of DJVU files to TIFF files by parsing a JavaScript file?

You won't be able to do this with just Javascript, as javascript has no inherent access to the filesystem.

Options then:

  • Node.js: You can stand up a simple nodejs webserver which will allow you to access the filesystem, nodejs also has imagemagick module that you can install for processing images.
  • php: You could setup php on your local server which will give you access to the filesystem, and php extensions for image processing.
  • Python: It would be trivial for python to implement this, import numpy and write a simple looping script to get all the files and then do some magic.

The real problem at hand is determining how your renaming scheme can fit some neat rule from which to write an automated script.

Taking Example of DJVU file: 112_87_10_0.djvu
and convert/rename to: HEK_S044_Vitsand_1883-95.tif

There needs to be a pattern from which one can apply the following logic.

  1. Get all files in the directory to be converted.
  2. Sort by some important sorting value (is it numerical ascending?)
  3. Take each conversion in order of sort and name it to a corresponding value.

As of right now, you could easily write a script that converts all files such as this:

112_87_10_0.djvu ==> 112_87_10_0.tif

But until you can provide some additional ruleset for the renaming schema the rest of your question remains unanswerable.


Upon further review I do see that you provide some information in regards to getting the naming schema.. I shall look at that a bit more and revise my answer. If you could though, please remove all irrelevant information from your question, specificially the start and index.html bits, there is really nothing in that code of any importance to the question, and merely serves to obfuscate the important bits.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.