Last active
February 16, 2024 19:29
-
-
Save maforget/48103d7bc7986b6c76cdf422dab755df to your computer and use it in GitHub Desktop.
Create CBL from a Text File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re; | |
import os; | |
with open('sorting.txt') as f: | |
lines = f.readlines() | |
with open('template.cbl') as f: | |
cbl = f.read() | |
for l in lines: | |
l = re.sub(r"\..+|\n", "", l, 0, re.IGNORECASE | re.DOTALL)#remove file extension and/or the newline char | |
filename = 'output/' + l + '.cbl' | |
os.makedirs(os.path.dirname(filename), exist_ok=True)#Create the output dir if doeasn't exists | |
newCbl = cbl.replace('Book Name', l) | |
with open(filename, 'w') as f: | |
f.write(newCbl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test File 001 | |
Test File 002.cbz | |
Test File 003.cbr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<ReadingList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<Name>Book Name</Name> | |
<Books /> | |
<Matchers> | |
<ComicBookMatcher xsi:type="ComicBookFileMatcher" MatchOperator="3"> | |
<MatchValue>Book Name</MatchValue> | |
</ComicBookMatcher> | |
</Matchers> | |
</ReadingList> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment