View Full Version : Script to convert a directory full of files?


mdibella
10-14-2008, 12:38 PM
In the 'some people are never satisfied' category...and trying real hard not to violate forum rules...


Let's assume that I have a folder full of EBooks on my Windows desktop. They are in a format that will not work on my soon-to-arrive Sony reader.

Also assume that I have a Python script (call it 'MobiDeXXX') that will magically change them into something that I can load into Calibre and then do a batch-convert to the format Sony loves.

Is there a script (or could some genius write one) that would take this entire directory and run the magic Python script against each file, one at a time, and save the results into a different directory?

Note that I am being purely lazy here, since I can of course type in the 200 file names, one at a time, into the command window and run the Python script against them.

But if anyone can help with this, I would be most grateful! :thanks:

pilotbob
10-14-2008, 01:37 PM
Also assume that I have a Python script (call it 'MobiDeXXX') that will magically change them into something that I can load into Calibre and then do a batch-convert to the format Sony loves.

But if anyone can help with this, I would be most grateful! :thanks:
You can create a batch file... debulk.bat with the following line in it:

for %%i in (*.prc) do MobiDeXXX.py %%i %%~ni_free.prc PID

Hypothetically of course. You could even get a bit more fancy and add an IF NOT EXISTS to it to only run the command if the _free file doesn't exist. I think adding an /R after the for and it will recurse directories also.

BOb

mdibella
10-14-2008, 02:21 PM
Worked great, thanks so much!!!