Welcome, Guest
Python Scripts for ComicRack
  • Page:
  • 1
  • 2

TOPIC: Rename comics automatically - alternate version

Rename comics automatically - alternate version 9 years 11 months ago #139

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
Here's a package of this script you can extract to the ComicRack scripts folder and use this rename template without replacing the original one. Includes an icon as well. Look for it in the right click->Automation menu as \"Rename Files\".

File Attachment:

File Name: RenameFile...sion.zip
File Size:1 KB


I like maintaining consistant file sorting
even when I'm not using Windows native file
explorers. Files named

Comic #001.cbz, ... , Comic #099, Comic #100

will not be sorted identically to the above
if renamed

Comic #1, ... , Comic #99, Comic #100

as the current renaming script does.

I offer an alternate version that maintains
the zero padding for the series number and
doesn't prepend the number with the pound
sign #. Non-numeric series numbers will
simply appear in the Number spot without
change.

[code:1]
#
# Rename Book Files to
# 'Series Volume Number (of Count) (Year)'
# Maintains zero padding for books with
# ShadowNumber values less than 100
# Non-numeric ShadowNumber values are not
# padded

def RenameBookFiles(books):
for book in books:
series = book.ShadowSeries
volume = \"\"
numeral = \"\"
count = \"\"
year = \"\"
if series != \"\":
if book.ShadowVolume != -1:
volume = \" V\" + str(book.ShadowVolume)
if book.ShadowNumber != \"\":
try:
numeral = \"%.3d\" % int(book.ShadowNumber)
if (book.ShadowCount > 0):
count = \"%.3d\" % book.ShadowCount
count = \" (of \" + count + \")\"
except ValueError:
numeral = book.ShadowNumber
if len(numeral) > 0:
numeral = \" \" + numeral
if book.ShadowYear > 1900:
year = \" (\" + str(book.ShadowYear) + \")\"
name = series + volume + numeral + count + year
book.RenameFile (name)[/code:1]
Last Edit: 9 years 11 months ago by wadegiles.
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #181

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
MOVED INFORMATION TO THE FIRST POST.
Attachments:
Last Edit: 9 years 11 months ago by wadegiles.
The administrator has disabled public write access.

Filename patterns 9 years 11 months ago #186

Hi,

I don't know Python, but is it possible to create dialog boxes?

I thought about a creating a text file with a list of filename patterns like this:
Format1=%Imprint - %Series - %Number - V%Volume
Format2=%Series V%Volume #%Number

and the dialog would ask the user what's the filename pattern to be used. Or ask the user to create a new one (using a standard edit - the result would be appended to the file).

Well, just wondering...
The administrator has disabled public write access.

Re:Filename patterns 9 years 11 months ago #187

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
I'm working on something. Should have it done today or tomorrow.
The administrator has disabled public write access.

Re:Filename patterns 9 years 11 months ago #189

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
I skipped the file saving bit but I did implement a user specified renaming function. I posted all the information and a zip file with the script and xml at http://comicrack.cyolito.com/index.php?option=com_kunena&Itemid=9&func=view&catid=13&id=188#188
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #282

  • thavinci
  • thavinci's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 8
  • Karma: 0
I noticed A problem with the renaming when there was a : in the series.
So I added this line just before the renaming-line. It works fine now.

series = series.replace(':',' -')
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #283

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
You're right about renames failing when the new name will contain a colon. That's that the OS file naming convention getting in the way.

Reserved characters not allowed in filenames on Windows NTFS file systems are

&gt &lt : \" / \ |
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #298

  • Knight Rider
  • Knight Rider's Avatar
  • Offline
  • Expert Boarder
  • Posts: 135
  • Thank you received: 11
  • Karma: 16
thavinci wrote:
I noticed A problem with the renaming when there was a : in the series.
So I added this line just before the renaming-line. It works fine now.

series = series.replace(':',' -')

could you explain better, i don't understood were i put this line
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #302

  • wadegiles
  • wadegiles's Avatar
  • Offline
  • Gold Boarder
  • Posts: 248
  • Thank you received: 3
  • Karma: 20
Put the line in before these lines in the script like the following to replace colons with a space and a dash. The line you add is the first one.

series = series.replace( ':',' -' )
name = series + volume + numeral + count + year
book.RenameFile (name)

If the series name in ComicRack is Batman: Legends of the Dark Knight, The script will rename the file using Batman - Legends of the Dark Knight instead.
Last Edit: 9 years 9 months ago by wadegiles.
The administrator has disabled public write access.

Re:Rename comics automatically - alternate version 9 years 11 months ago #304

  • Knight Rider
  • Knight Rider's Avatar
  • Offline
  • Expert Boarder
  • Posts: 135
  • Thank you received: 11
  • Karma: 16
thank you very much.
last question, how i put the \"#\" before the number?

edit
sorry, i could find, thanks again for the great script
Last Edit: 9 years 11 months ago by Knight Rider.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.243 seconds

Who's Online

We have 234 guests and 9 members online