Welcome, Guest
Python Scripts for ComicRack

TOPIC: Standardize Library files

Standardize Library files 9 years 3 weeks ago #2286

So after some testing, this is ready to launch. This script will do a number of things:
-Standardize file names to "[Series] [v# if any] [Number]"
-Create a new folder structure of "[Publisher]\[Imprint]\[Series] [v# if any]"
-Move the file to the new folder and update Comicrack with the new location
-Remove the previous folder if it is empty

You can modify this as needed to change the format of the file name/folders, this is just the system I use.

IMPORTANT! Before using, edit the script in a text editor and change the following line:

rootfolder="NOTAFOLDER"

Change NOTAFOLDER to the path of your chosen "root" comic directory. Don't forget to use \\ instead of \, and also end it with \\. For instance:

rootfolder="C:\\users\\brian\\desktop\\comics\\"

I've tested this extensively, and it works very well. As always, your actual mileage may vary, so be cautious and test this out on your own before you blindly run it on your entire library. I don't want to be the reason you destroy your library (though it works well as far as I can tell :))

Thanks to Quaraxkad for the core of this code as well as me stealing his log lines :)

UPDATE: Can't seem to attach the newest version... look for it on a reply later in the thread.
Attachments:
Last Edit: 9 years 2 weeks ago by DouglasBubbletrousers.
The administrator has disabled public write access.

Re:Standardize Library files 9 years 3 weeks ago #2288

  • Quaraxkad
  • Quaraxkad's Avatar
  • Offline
  • Senior Boarder
  • Posts: 61
  • Karma: 2
Quick idea: You could simplify the customization of file paths and names for users. Save each value you want to use in a variable, and let the user edit a string value like this (using your example):
"%publisher%\%imprint%\%series% %vol%\%series% %vol% %number%"
Then just do string.Replace("%publisher%",strPublisher).etc...

PS: You used my status log lines! ;)
The administrator has disabled public write access.

Re:Standardize Library files 9 years 3 weeks ago #2289

Ah, true, and I will credit you accordingly :)
The administrator has disabled public write access.

Re:Standardize Library files 9 years 3 weeks ago #2290

  • Knight Rider
  • Knight Rider's Avatar
  • Offline
  • Expert Boarder
  • Posts: 135
  • Thank you received: 11
  • Karma: 16
Could this script only:
Create a new folder structure of "[Publisher]\[Imprint]\[Series] [v# if any]"
-Move the file to the new folder and update Comicrack with the new location
-Remove the previous folder if it is empty.

without the file renaming?
The administrator has disabled public write access.

Re:Standardize Library files 9 years 3 weeks ago #2291

  • Quaraxkad
  • Quaraxkad's Avatar
  • Offline
  • Senior Boarder
  • Posts: 61
  • Karma: 2
rgponce wrote:
Could this script only:
Create a new folder structure of "[Publisher]\[Imprint]\[Series] [v# if any]"
-Move the file to the new folder and update Comicrack with the new location
-Remove the previous folder if it is empty.

without the file renaming?

Change line 58 from this:
fullnew=dir+name+fi.Extension

To this:
fullnew=dir+book.FileName+fi.Extension

You're basically just having it ignore the new filename variable name, and setting the new filename to the same as the old.
The administrator has disabled public write access.

Re:Standardize Library files 9 years 2 weeks ago #2306

Made some stability changes. Wrapped the file move with a try/except, so it shouldn't throw any error messages and continue until the end of the selection.

Also, to improve my scanning times (sometimes on my storage server across my network), I modified the script to not remove a folder called !TOLOAD. Then I switched my CR preferences to only scan a !TOLOAD folder. If you use that for loading new files and standardizing from there, I think you'll find adding new files and maintaining them becomes a lot easier start to finish.

Anyway, the script has been uploaded here. Can't seem to edit the original reply and add the new file.

File Attachment:

File Name: Standardiz...ary1.zip
File Size:2 KB
Last Edit: 9 years 2 weeks ago by DouglasBubbletrousers.
The administrator has disabled public write access.

Re:Standardize Library files 9 years 1 week ago #2324

  • Hochler
  • Hochler's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 8
  • Karma: 0
I'm getting a "No module named os", some dependency I'm missing maybe?

ComicRack v0.9.96 32bit
The administrator has disabled public write access.

Re:Standardize Library files 9 years 1 week ago #2327

The OS module is standard in python 2.5's windows install... make sure you've included your python install's lib and lib\site-packages folders in CR's scripting preferences.
The administrator has disabled public write access.

Re:Standardize Library files 9 years 1 week ago #2329

  • Hochler
  • Hochler's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 8
  • Karma: 0
Just added 'C:\Python26\Lib' and 'C:\Python26\Lib\site-packages' to the scripting preferences, but now I'm getting an "unexpected token" error.
The administrator has disabled public write access.

Re:Standardize Library files 9 years 1 week ago #2330

  • Knight Rider
  • Knight Rider's Avatar
  • Offline
  • Expert Boarder
  • Posts: 135
  • Thank you received: 11
  • Karma: 16
Find:
import clr, re, nt, time, os

Replace for:
import clr, re, nt, time

Find:
os.rmdir(oldpath)

Replace for:
nt.rmdir(oldpath)

with me this works without install python
Last Edit: 9 years 1 week ago by Knight Rider.
The administrator has disabled public write access.
Time to create page: 0.201 seconds

Who's Online

We have 212 guests and 10 members online