Closed naarcissus closed 2 years ago
It currently does not have a "batch" mode, but I modified it to accept input args, so it would work as a module. Then, it should be trivial to just list the files first and then convert them one by one.
Below is an example you can adopt (just put it side-by-side with chapter_converter.py and run it. Change the p
to the folder path you want to work on. It would recursively convert all the .pbfs in that folder (or in its subfolder) to .xml.)
from pathlib import Path
from chapter_converter import main
# put the parent folder here:
p = R"D:\temp\test"
p = Path(p)
for f in p.rglob("*.pbf"): #rglob is recursive. Use `glob`` if you don't want that.
print(f)
options = [
'-f', 'xml',
]
main(str(f), *options)
Also thanks for your kind words, I'm glad it helps people.
Thank you very much! That will work for me, and does.
Took seconds to iterate through the files instead of minutes to run one file, wait for prompt, press up for previous, put cursor next to changed number for next file, delete number, input new number, enter, repeat. Much faster and easier this way.
Thanks again.
I'm trying to use this script to convert an entire folder of
*.pbf
files to*.xml
files. Actually, I have many folders of them to convert. But this script doesn't seem to support wildcards like*
and?
and Windows Shell does not take care of this itself. According to what I could find, you need to include the functionality in your script, something called a glob module. Otherwise I have hundreds of files to input manually or at least, slowly. Though, I suppose if it could take multiple input files and process them by turns, that might work too.https://stackoverflow.com/questions/405652/passing-arguments-with-wildcards-to-a-python-script
That is what I found, it seems simple, but I know next to nothing about python. I very much appreciate this script, even missing this functionality, it's saved me a lot of time and effort, thank you for creating it.