Welcome, Guest
Python Scripts for ComicRack

TOPIC: List Comic Files n Directory-New Script 4 Testing

List Comic Files n Directory-New Script 4 Testing 7 years 8 months ago #5191

  • oraclexview
  • oraclexview's Avatar
  • Offline
  • Moderator
  • aka SoundWave
  • Posts: 906
  • Thank you received: 182
  • Karma: 37
Hello everyone!

This is the first stage in creating the next script that I'm working on. What this test script does at this stage is list all CBR & CBZ files located in a user selected directory and all it's sub-directories. The script was written in VBScript, but later on it will be converted to IronPython once I'm ready to integrate it with the ComicRack library.

I have written two versions of the script. The first version outputs all found CBR & CBZ files to a simple TXT file. The other version outputs the same information to a XLSX file if the user has Excel 2007 installed, a XLS file if the user has Excel 2000 to Excel 2003 installed, or exits the script if any older version of Excel is installed or no version of Excel is found.

The text file version of the script is much faster than the Excel version. However, I've seem to have reached a limitation of the text file version once the text file grows to the size of about 1.5 MB. It takes my laptop about 30 minutes to reach this file size as it goes through the over 20,000 comic files in my directory. I haven't counted exactly how many files it has gone through before failing but by my calculations I want to say it reached a log of roughly 14,000 eComics before getting an error. At first I thought this error was due to TXT file size limitations, but based on the research I've done thus far, Windows Vista can handle TXT file sizes much larger than this. I think only as far back as Windows 3.1 or Windows 95/98 would this file size have been a problem. So, until further research and testing can be done, I will say that as long as your directory contains under 10,000 to 12,000 files in Windows XP (XP has been tested to work properly, but not tested with a directory with a LARGE number of eComic files) and beyond.

The Excel file version of the script isn't has fast as the text file version for obvious reasons. I'm still running the script against my directory of files, and the good news is that it hasn't crashed. The bad news is that it's still running 3 1/2 hours later. When I first tested this version successfully, it was with a directory of about 60 eComic files. This took a maximum of 3 minutes to run. So now, with my directory of over 20,000 books, it's probably only gone through 4,200 books thus far. The file is also up to 135 KB in size thus far.
I haven't tested this script version with other versions of Excel yet. However, the script is written to create and write to a XLS file if the user isn't using a computer with Excel 2007 installed and to exit the script if there is either an Excel older than 2000 installed or no Excel installed at all.

So, this is far from perfect as it is, but it is a starting point for wanting to include a log file for what the script does when converting/copying CBR files to CBZ format.

This script runs outside of ComicRack at this point, and it doesn't damage or change any of your files. This is a VBScript which requires Windows installed. If you choose to test the Excel version, it is currently written for computers with Excel 2000 and beyond installed.
Again, this script at this point only catalogs your CBR and CBZ files in a directory that the user specifies.

I have changed all the "WScript Echo" to screen display in both scripts to code comments. For those that want to edit the scripts for testing themselves you can change these comments back to screen echos for more details on what the script is doing.

Since this is only for testing purposes, I haven't detailed the code with many explanation comments yet.


Here is a quick walk through of what the text script does.
It first prompts the user to select a directory. You have three options here:
1) Cancel button which exits the script
2) New Folder button which user can create a new folder
3) OK button to work with the folder user has selected

Once the OK button is clicked, the user is then prompted with another three options here:
1)Cancel button which exits the script
2) No button if user wants to convert CBR to CBZ file and delete original CBR file (this button is disabled but that is what it will eventually do when clicked)
3) Yes button is user wants to convert CBR to CBZ file and keep original CBR file (this button is disabled but that is what it will eventually do when clicked)

Once either the No or Yes button is clicked, the script then creates a text file named "ComicFileList.txt" in the same directory that the user selected. It then checks to see if there are any CBR/CBZ eComic files in the directory or sub-directory. Once it finds the first eComic file, it lets the user know this with a prompt.
Once the user clicks the OK button, the script them proceeds with logging each file it finds in the directory to the created text file.
At the end of this process, the script prompts that it completed successfully.
It's done!


Here is a quick walk through of what the Excel script does.
It first prompts the user to select a directory. You have three options here:
1) Cancel button which exits the script
2) New Folder button which user can create a new folder
3) OK button to work with the folder user has selected

Once the OK button is clicked, the user is then prompted with another three options here:
1)Cancel button which exits the script
2) No button if user wants to convert CBR to CBZ file and delete original CBR file (this button is disabled but that is what it will eventually do when clicked)
3) Yes button is user wants to convert CBR to CBZ file and keep original CBR file (this button is disabled but that is what it will eventually do when clicked)

Once either the No or Yes button is clicked, the script then creates an Excel file named "ComicFileList.xlsx" or "ComicFileList.xls" in the same directory that the user selected. This is only if computer has Excel version 2000 to 2007 installed, otherwise the scripts exits. It then checks to see if there are any CBR/CBZ eComic files in the directory or sub-directory. Once it finds the first eComic file, it lets the user know this with a prompt.
Once the user clicks the OK button, the script them proceeds with logging each file it finds in the directory to the created Excel file.
At the end of this process, the script prompts that it completed successfully.
It's done!


There you go! At lot said for such a simple script. If you run into any issues or errors, let me know in detail what you encountered and what environment you were working in.

Thanks everyone!

File Attachment:

File Name: ListComicF...ory0.zip
File Size:4 KB
The administrator has disabled public write access.

Re:List Comic Files n Directory-New Script 4 Testing 7 years 8 months ago #5232

  • Stonepaw
  • Stonepaw's Avatar
  • Offline
  • Moderator
  • Posts: 920
  • Thank you received: 267
  • Karma: 173
I had no problems running this on a Windows 7 64-bit computer. The txt script indexed around 2150 cbz/r files in around a minute. The xls script took longer, about 10 minutes or so, but it successfully found all the comics as well.
The administrator has disabled public write access.

Re:List Comic Files n Directory-New Script 4 Testing 7 years 8 months ago #5233

  • oraclexview
  • oraclexview's Avatar
  • Offline
  • Moderator
  • aka SoundWave
  • Posts: 906
  • Thank you received: 182
  • Karma: 37
The speed improvement for you is great to know! Test I performed were on my Windows Vista 32-bit 2GB RAM system. Again, the TXT script crashed after 30 minutes to go through 14,000 CBR/CBZ files. The XLSX/XLS script completed successfully on my full directory of 24,000 CBR/CBZ files, though this processed a dismal average of 20 files a minute which came to a total of 20.5 hours to run. Way, way, way too long for my taste!


ADDED NOTE:
Also, to let everyone know, I believe the main reason this script takes so long to run, is the fact that it doesn't just add a log of a eComic file to the text/Excel list as it's found. What it does is it first checks to see if that eComic file has already been recorded in your log text/Excel file. if it has, it ignores this eComic file and moves on to the next. If it hasn't, then it commits a log of that eComic file to the text/Excel list. This was done so that the same file wasn't logged twice, for example, in situations where you ran the script again on the same directory.
Last Edit: 7 years 8 months ago by oraclexview.
The administrator has disabled public write access.
Time to create page: 0.175 seconds

Who's Online

We have 203 guests and 5 members online