Welcome, Guest
Python Scripts for ComicRack

TOPIC: malor89's Perl Scripts

Re: malor89's Perl Scripts 7 years 3 weeks ago #11103

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
600WPMPO wrote:
Many a times, we have the archived files named simply.. scan001.jpg, scan002.jpg..., or P0001.jpg, P0002.jpg.., or Page_00001.jpg, Page_00002.jpg. Extracting a page (without using ComicRack) from such an archive leaves no meaningful information in its filename. So, if suppose the archive name can be appended to the individual jpgs inside, extracted files would say a lot about their sources..

e.g. P0001.jpg would be Infinite Crisis 01 (2005) (RIP_ODB-DCP) P0001.jpg

This could also come in handy when you wish to manually compare 2 copies of a page from 2 different scanners.
This is why I always extract archives to a folder named after the archives. Which is another reason to like 7-Zip, since you can right click on cbr/cbz files and select 'extract to "archive name\"' for a single archive or 'extract to "*\"' for multiple archives.

Let me know if that doesn't meet your need.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 7 years 3 weeks ago #11104

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
malor89 wrote:
This is why I always extract archives to a folder named after the archives. Which is another reason to like 7-Zip, since you can right click on cbr/cbz files and select 'extract to "archive name\"' for a single archive or 'extract to "*\"' for multiple archives.
Let me know if that doesn't meet your need.
Yes, I fully agree with you there. However, even in that case, the filenames are still the same monotonous P0001.jpg, P0002.jpg. I would like to save some individual pages from various archives, and the script can help in naming the pages meaningfully.


;) And while we are at it, Here is another request (hope you don't get angry for me asking so much !):

A script called something like addvariant.pl

I often like to add variant covers to an existing archive. An addvariant.pl script could make this very easy. All it would require is that the archive and the cover have comparable file names. For example, for an archive like:
Incredible Hulks 614 (2010) (Minutemen-Fiji).cbr
the variant is:
Incredible Hulks 614 (2010) (Salvador Espin Vampire Variant) (Cover ONLY) (ScanDog).jpg
The script would search for the variant jpg in the archive directory (and if possible, in the sub-directories) and add the variant jpg to the matching archive.

I know that you are the magician of Perl, my friend.. and you can conjure up almost any script with it !! :cheer:
Now Playing: The ComicRack Manual (Online)

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

Re: malor89's Perl Scripts 7 years 3 weeks ago #11106

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
addfoldername.pl
Adds the parent folder name to all the file names in the current directory
Usage: Just place it in the folder with the files you want to change are double click it.

addfoldername.bat
Adds the parent folder name to all the files in directory or to individual files
Usage: Either drag the files you want to change onto addfoldername.bat or drag one or more folders onto it to rename the files that they contain. You could also place addfoldername.bat into Windows' "Send To" folder and use it that way.
Note for addfoldername.bat: If the directory for the perl.exe isn't in Windows' Path Environmental Variable, you'll either need to add it there or edit addfoldername.bat to include the full path to perl.exe where it says "perl -x"...

Both versions prompt 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. addfoldername.bat gives a new prompt for every folder it is called with.
Attachments:
Last Edit: 7 years 3 weeks ago by malor89.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 7 years 3 weeks ago #11108

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
Thanks.. that was fast ! :)
malor89 wrote:
If the directory for the perl.exe isn't in Windows' Path Environmental Variable, you'll either need to add it there or edit addfoldername.bat to include the full path to perl.exe where it says "perl -x"...
The bat file just says "done". I tried to add the full path to perl.exe , but i think i am not doing it properly:

addfoldername.pl works fine as it promises.

:unsure: However, this needs an extra step in that all the files have to be extracted from the cbz/cbr to the named folder. I was wondering if that could be done directly on the archive (without actually extracting the files), it would be more useful. Still, it is a good script..

p.s. now waiting for addvariant.pl ;)
Now Playing: The ComicRack Manual (Online)

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

Re: malor89's Perl Scripts 7 years 3 weeks ago #11109

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
600WPMPO wrote:
The bat file just says "done". I tried to add the full path to perl.exe , but i think i am not doing it properly:
Since the done message is printed using perl, that means that it is working.

I might not have been clear enough on my instructions. You need to drag files or folders onto the icon for addfoldername.bat. You can't drag the stuff onto it after it is running.
Last Edit: 7 years 3 weeks ago by malor89.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 7 years 3 weeks ago #11110

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
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
- Also strips numbered files of the original name while keeping the number. This can be disabled.
- Renaming can be disabled, so that it just extracts the archive into a single folder with no subfolders.
- I used the graphical version of 7-zip this time, if you don't like the pop up window just change 7zg.exe to 7z.exe in the .bat file.

Usage: Drag the archive(s) you want to extract onto the icon for extract&rename.bat. You could also place extract&rename.bat into Windows' "Send To" folder and use it that way.

Note: 7-Zip must be installed for this script to work. The path to 7zg.exe can be set in the script if the default isn't correct.
If the directory for the perl.exe isn't in Windows' Path Environmental Variable, you'll either need to add it there or edit addfoldername.bat to include the full path to perl.exe where it says "perl -x"...
Attachments:
Last Edit: 7 years 3 weeks ago by malor89.
The administrator has disabled public write access.

Re: malor89's Perl Scripts 7 years 3 weeks ago #11111

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
extract&rename.bat is a very good step forward for the addfoldername.bat script.

It is working fine... all thank malor the mighty !! :)
malor89 wrote:
I used the graphical version of 7-zip this time, if you don't like the pop up window just change 7zg.exe to 7z.exe in the .bat file.
Actually, the GUI is better !!
malor89 wrote:
You could also place extract&rename.bat into Windows' "Send To" folder and use it that way.
For users who do not know how to add items to the 'send to' menu, here is an easy way (for Windows 7):
To open up SendTo folder directly, just type shell:sendto into Start Search or Run command. The SendTo folder will be opened in a Windows Explorer window to allow users to customize the items to appear on “Send To” menu by drag and drop or copy and paste shortcuts to the folder.
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 7 years 2 weeks ago #11121

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
malor89 wrote:
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
600WPMPO wrote:
extract&rename.bat is a very good step forward for the addfoldername.bat script.
I was wondering if it would be possible to go another step forward.. so that we get extract --> rename --> re-archive.

This would save the hassle of deleting the old archive manually and making a cbz/cbr from the new folder (having properly prefixed filenames). Also, this would come in handy when sometimes a corrupt archive is healed by extracting and re-archiving it.

Basically, after extracting an archive and prefixing its filenames, the script can use 7zip/winrar to again archive the folder into a cbr/cbz that replaces the original archive. Saving any individual page from the new cbz/cbr (using any comic reading software) would ensure a properly prefixed filename.

I hope it won't be difficult for malor the mighty B)

p.s. did you like the script logo (first post) ?
Now Playing: The ComicRack Manual (Online)

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

Re: malor89's Perl Scripts 7 years 2 weeks ago #11125

  • malor89
  • malor89's Avatar
  • Offline
  • Senior Boarder
  • Posts: 73
  • Thank you received: 16
  • Karma: 17
600WPMPO wrote:
I was wondering if it would be possible to go another step forward.. so that we get extract --> rename --> re-archive.
p.s. did you like the script logo (first post) ?

The logo looks fine, it gives the first post a little more flare.

Here is the script modified to rearchive. It has the option to delete or rename the original archive and an option to remove the folder with the uncompressed files. You'll probably want to keep the stripname option set to 0 to ensure the page sort order doesn't get changed.

I'll leave it as an unoffical script, unless other people show a demand for it.
Attachments:
The administrator has disabled public write access.
The following user(s) said Thank You: 600WPMPO

Re: malor89's Perl Scripts 7 years 2 weeks ago #11126

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
malor89 wrote:
Here is the script modified to rearchive. It has the option to delete or rename the original archive and an option to remove the folder with the uncompressed files. You'll probably want to keep the stripname option set to 0 to ensure the page sort order doesn't get changed.

I'll leave it as an unoffical script, unless other people show a demand for it.
Wow!.. Thanks a lot malor.. i appreciate this as a personal favor.. :)
+1 karma follows..
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
The administrator has disabled public write access.
Time to create page: 0.231 seconds

Who's Online

We have 266 guests and 3 members online