Welcome, Guest
Python Scripts for ComicRack

TOPIC: malor89's Perl Scripts

malor89's Perl Scripts 6 years 11 months ago #10940

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
ComicRack is proud to present malor89's perl scripts:
an excellent compilation of a number of scripts for managing your eComic collection in windows explorer.

I've written a bunch of utility scripts in Perl for my own use, but I'd be willing to share them if there is enough interest. If you never use the command prompt, then this probably isn't for you.

To use these scripts you will need to have a Perl interpreter installed. I use ActivePerl by ActiveState.
  1. Install ActivePerl or another Perl interpreter
  2. Place the perl script in the directory you want to process.
  3. Double click the scriptname.pl file
Attempts to fix file names that have had all the special characters changed to spaces or underscores. Standardizes spacing around parentheses, removes double file types and sets file type to lower case, adds parentheses around year, ctc, c2c, noads, fixed, of pages, of covers, scanner, adds parentheses around number of issues in limited series. [ex. (of 4)], removes file copy number at end of file name. [ex. filename (2)].
  • checktype.pl
checks to see if .cbz files are actually .cbr files and vice versa. I found a surprising number of files with the incorrect type in my library. Any renamed files will be listed in the file "renamed.txt" that the script uses/creates.

Note: Both the above scripts (fixnames.pl & checktype.pl) were written to work recursively on subdirectories, but for the sake of safety I have disabled it. You can re-enable it by removing the "#" from #listdir ("$dir/$file");

Attempts to match the comic name to existing directories and then moves them accordingly. This script checks the parent directory for matching names and sorts the comics accordingly, any comics that don't match are place in the misc directory. Duplicate files aren't moved and remain in the current directory.
Looks in the current directory and makes a new subdirectory if there are 5 or more files with similar names. The threshold number for creating new directories can be changed by using notepad to edit the .pl file.
makesort.pl scans the comic directory recursively and makes a list of the titles it finds and where it found them. listsort.pl can then be used to sort the comics in the directory in which it is run. You can choose a custom path for the file being moved by pressing 'c' and 'enter' and a new entry will be added to the "customlist.txt" file.
testarchives.pl tests all the archives of the matching file types in the current directory and subdirectories.The results are saved in a text file named "corrupt.txt". 7-Zip must be installed for this script to work.
setmodified.pl sets the modified date of an archive based on the date of the newest image file it contains. This script can also delete non-image files from archive, checks if cbr is cbz or vice versa, can attempt to restore the file name of an archive from the folder name stored in the archive, can test archives for errors, and checks if cbr or cbz contains other archives, renames them back to rar or zip if they do.
addfoldername.pl adds the parent folder name to all the file names in the current directory. It prompts you to confirm that you want to prefix the file names with the folder's name. You can press 'c' and 'enter' to choose a custom prefix.
extract&rename.bat extracts an archive into a folder named after the archive and prefixes each extracted file's name with the archive's name. It also strips numbered files of the original name while keeping the number.
undorenamed.pl lets you easily undo any name changes made by setmodified.pl and/or fixnames.pl. This script reads the renamed.txt file and changes the file names back to the original names.
addvariant.pl places image files in the current directory into comic archives with matching names. By default it will move any placed images to a folder named "done" if it exists. There is an option in the script to delete the original image file instead.
finddups.pl scans for duplicate files in archives. The script can set the minimum number of matched files before listing, and can skip listing old matches.
folder-namer.pl adds/updates year and mini-series suffix at end of folder name. You can turn off the mini-series style and the complete/ongoing tag for the mini-series style.
finddupversions.pl looks for both the c2c and noads version of the same comic archive. You can set it to keep either the c2c or the noads version.
Attachments:
Last Edit: 6 years 8 months ago by 600WPMPO. Reason: updated index 2011_02_16
The administrator has disabled public write access.
The following user(s) said Thank You: 600WPMPO

Re: malor89's Perl Scripts 6 years 11 months ago #10947

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 232
malor89 wrote:
I've written a bunch of utility scripts in Perl for my own use, but I'd be willing to share them if there is enough interest. If you never use the command prompt, then this probably isn't for you.

To use these scripts you will need to have a Perl interpreter installed. I use ActivePerl by ActiveState.

The scripts look very promising.. In Fact, I've been looking for such scripts for a long time, but could never find a good one.

Too bad, I do not know anything about Perl :(

I would, however, like to use the scripts.. would it be possible for you to provide an outline of steps required ? :unsure:
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
Last Edit: 6 years 11 months ago by 600WPMPO.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10948

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
Actually to just use these scripts it shouldn't be too complicated.
1. Install ActivePerl or another Perl interpreter
2. Place the perl script in the directory you want to process.
3. Double click the scriptname.pl file

I believe the ActivePerl Installation program asks to associate .pl files with the Perl Command Line Interpreter, if that wasn't done you just need to associate it with perl.exe found in the "bin" directory of wherever you installed Perl.
Last Edit: 6 years 11 months ago by malor89.
The administrator has disabled public write access.
The following user(s) said Thank You: 600WPMPO

Re: malor89's Perl Scripts 6 years 11 months ago #10949

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 232
malor89 wrote:
Actually to just use these scripts it shouldn't be too complicated.
1. Install ActivePerl or another Perl interpreter
2. Place the perl script in the directory you want to process.
3. Double click the scriptname.pl file
Yes.. it really wasn't that hard after you told the steps ! :)

i just make a dummy file:



then i do steps 2 & 3:



The only problem is that i want the brackets in the end around the scanners' name also..
e.g. Avengers 4 Preview 02 (of 03) (2010) (Minutemen-DTs).cbz

Would that be possible ?

In the meantime, enjoy a well-deserved +1 karma from me..! :)

malor89 wrote:
Some other scripts I could share are one the does simple file sorting, one that sets the modified date to the oldest file date in the archive, one that deletes non-image files (thumbs.db, links, etc.) from archives, a simple duplicate file finder. I don't want to waste time posting things people don't want, so speak up if something interests you.

Please post these scripts also.. they look very promising and would be quite useful !!
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
Last Edit: 6 years 11 months ago by 600WPMPO.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10955

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
Actually your example was missing the ending underscore it should have been "Avengers_4_Preview_02__of_03___2010___Minutemen-DTs_.cbz"

If this is a recurring problem, it shouldn't be too hard to fix, the difficulty usually lies in making sure the fix doesn't break something else.
Last Edit: 6 years 11 months ago by malor89.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10958

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
comicsort.pl
Here is a simple sorting script that attempts to match the comic name to existing directories and then moves them accordingly. It's setup to work the way I do things, which is placing all new comics in a subdirectory of the the main comic directory. comicsort.pl checks the parent directory for matching names and sorts the comics accordingly, any comics that don't match are place in the misc directory. Duplicate files aren't moved and remain in the current directory.

The first two lines of comicsort.pl can be edited if you want to arrange things differently. If the misc directory doesn't exist, the non matching comics won't be moved. Use notepad or another text editor to edit any of the .pl files.

Instructions:
Place your unsorted comics in a seperate folder in your main comics folder. Place comicsort.pl in that folder. Make a "misc" folder in the main comics folder to store non-matching comcis. Double click comicsort.pl to sort. (must already have Perl setup, see earlier post)
Attachments:
Last Edit: 6 years 11 months ago by malor89.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10960

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 232
malor89 wrote:
Actually your example was missing the ending underscore it should have been "Avengers_4_Preview_02__of_03___2010___Minutemen-DTs_.cbz"
Yes.. I noted that.. and now it is working fine.. thanks!
malor89 wrote:
comicsort.plIt's setup to work the way I do things, which is placing all new comics in a subdirectory of the the main comic directory. comicsort.pl checks the parent directory for matching names and sorts the comics accordingly, any comics that don't match are place in the misc directory.
Well..this is also an excellent script and does what it promises. More karma your way malor89 !! :)

However, i have a little query.. My main comics folder is the D drive. I keep my comics within folders of their respective publishers, like:
D:\Boom\28 Days Later
Sometimes, it gets tricky.. when we have more sub-folders (more in the name of better organization ;) )
D:\Marvel\Avengers\Avengers [Vol. 4] [2010] [ongoing]
D:\Marvel\Avengers\Avengers Academy [2010] [ongoing]
Currently, to make good use of the comicsort script, I follow these steps:
  1. Run ComicVine Scraper on all 'raw' comics
  2. Group these unsorted comics by the publisher field
  3. Select all comics belonging to one publisher, and use the 'Move files' script to move them to an 'zzUncategorised' folder within their publisher folder
  4. Run the Comicsort script from within each publisher folder
I feel that this is one steps too many. Would it be possible for the comicsort script to search the sub-directories (and, while I'm feeling lucky, for sub-sub-directories) of the parent folder ? :unsure:

Also, currently the script moves the files into pre-existing folders having matching names. This implies that we have to manually make a folder for each new series. Could it (or some other script) make folders based on the names of the cbz file ?
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
Last Edit: 6 years 11 months ago by 600WPMPO.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10962

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
makedirs.pl
Looks in the current directory and makes a new subdirectory if there are 5 or more files with similar names.

Note: The script used to also sort the files into the new subdirectories, but I've found it works better to verify I like all the newly created directories first, and then run the comicsort.pl script after moving all the directories I want to keep to where they need to be. The threshold number for creating new directories can be changed by using notepad to edit the .pl file. To re-enable sorting, just remove the "#" from #rename in the .pl file.
Attachments:
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10965

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 232
600WPMPO wrote:
Could it (or some other script) make folders based on the names of the cbz file ?
malor89 wrote:
makedirs.pl
Looks in the current directory and makes a new subdirectory if there are 5 or more files with similar names.
B) How cool is that !! Man, you are good at this.. !
Again the script is very customizable. I just renamed the first line to make sub directories for minimum 2 files:
$minfiles = 2
Thanks a lot and a good +1 karma more ! (I can do this whole day :) )
600WPMPO wrote:
Would it be possible for the comicsort script to search the sub-directories (and, while I'm feeling lucky, for sub-sub-directories) of the parent folder ?
However, this query remains still unanswered..
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
The administrator has disabled public write access.

Re: malor89's Perl Scripts 6 years 11 months ago #10968

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 232
Facing some problems with the comicsort script..:(

When comicsort.pl checks the parent directory for matching names, it seems to require the exact name.

For example, when I try to sort comics named freak angels, it refuses to sort them into this folder:
Freak Angels [ongoing 2008] [Webcomic]
or this:
Freak Angels [Webcomic]
or even this:
Freak Angels Webcomic



The script successfully works only when I name the folder as simply:
Freak Angels
So, would it be possible to modify the script so that it matches the file name with the initial alphabets of the folder ?

It is notable that the script does not read the entire file name, but picks up just the series name from it. Similarly, it should also look for the series name in the folder name. fair, isn't it ? :unsure:
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
Last Edit: 6 years 11 months ago by 600WPMPO.
The administrator has disabled public write access.
Time to create page: 0.498 seconds

Who's Online

We have 238 guests and 5 members online