Convert PDF to Markdown in batches: How to process multiple files at once
Describes the general process of converting multiple PDFs to Markdown in batches, including file classification, scanning the documents for OCR first, unified output using scripts or batch tools, checking the results item by item, and what to look for when choosing a free tool.
Key points of this article
- First divide the PDF into a text version and a scanned version. The scanned version needs to be OCRed first, otherwise the converted Markdown will be empty or garbled.
- When there are more than a dozen files, use a script or a tool that supports batching to output them uniformly, which is less likely to be missed than manual conversion one by one.
- The output directory is separated from the original, and images are stored separately and referenced with relative paths to avoid invalid images in Markdown.
- After batch conversion, tables, formulas, and title levels need to be spot-checked. Machine conversion and OCR may cause errors, and important content needs to be checked manually.
Many people have a whole folder of PDFs, such as a collection of papers, technical manuals or conference materials, and want to convert them into Markdown and put them into a note library or static website for further editing. One-by-one conversion is acceptable when there are few files, but when there are too many files, it is easy to miss files and have confusing naming, and you have to double-check the settings. What is needed at this time is a set of batch processes, rather than the repetition of a single operation.
This article is written for readers who need to process a batch of PDFs but don’t want to do it manually one by one. After reading, you will know how to classify files, how to organize input and output directories, how to run a complete batch of files at once, and where to check after running. The method in this article is a general process and does not depend on a specific software.
Convert PDF to Markdown in batches, how to save trouble? One sentence conclusion
When there are few files and they are all text versions, just convert them one by one; when there are many files, first classify and unify the directory, then use a script or batch-supporting tool to run them all at once, and finally check the results randomly. Please see the table below for which method to choose.
| your situation | Recommended practices | reason |
|---|---|---|
| Within a dozen copies, all of which are text versions | Convert one by one using online conversion websites or desktop tools | Easy to set up and each result can be checked individually |
| From dozens to hundreds of copies, the layout is relatively uniform. | Use a command line conversion tool with a loop script | Executed once, the output naming and directory structure are unified |
| Contains scans | Perform OCR on the scanned document first, and then enter the conversion step. | The scanned document does not have a text layer, and direct conversion will result in blank or garbled characters. |
| Contains a large number of formulas and complex tables | After conversion, check one by one, and keep the original PDF comparison of key files. | Formulas and complex tables are easily misplaced or missing symbols |
| Confidential information involving contracts, medical records, etc. | Only use offline desktop programs or local scripts | Prevent files from being uploaded to unknown third-party servers |
Before you start: Confirm these points first
1. Distinguish between text version and scanned version. Open the PDF, try to select a piece of text with the mouse and copy it. The text version that can be selected and pasted is the text version, and the version that cannot be selected is usually the scanned document or image PDF. The two types of files must be processed separately, otherwise the scanned files will directly fail during conversion.
2. Count the total number of pages and files. Write down the number of pages in each PDF, even if it’s just a rough estimate. There is a significant difference in time consumption and error probability between a 30-page paper and a 300-page report. When the total amount is large, it is recommended to run in batches according to folders, and finish each batch before moving on to the next batch.
3. Determine the output structure. Decide whether a PDF corresponds to a .md file, or whether it should be split by chapters; decide where to place the pictures. A common practice is to create a images folder next to each document; decide whether the file name should use the original name. These agreements should be finalized before work begins, so that the subsequent scripts can be easily written.
4. Confirm confidentiality requirements. If the data involves contracts, medical records, or undisclosed research data, offline processing should be preferred, and the data destination of the tool used should be confirmed before conversion. This is more important than conversion quality to think about first.
5. Back up the original. Copy the PDF to be converted to a separate input folder, and all operations are performed on the copy only. If a conversion error occurs, you can always try again and the original will not be overwritten.
Steps to organize a batch of PDFs and convert them to Markdown
- Create two folders, input and output. Put the PDF copy in the input folder, and put the generated Markdown in the output folder. The two separate and the original remains intact.
- Divide PDF into subfolders according to text version and scanned version. This step can be judged one by one using the previous selection test. If there are many files, you can sample and judge first, and then put similar files together.
- Do OCR on the scanned version first. The function of OCR is to generate a recognizable text layer for scanned documents. The PDF editor of the OmniDoc desktop client provides an OCR function, which can process scanned documents one by one; the processed files then enter the conversion process.
- Select the conversion method and try it out with a small number of files. Select two or three representative documents (one with plain text, one with tables, and one with pictures) and convert them first to see if the titles, paragraphs, tables, and pictures are in line with expectations, and then expand the scope after confirmation.
- Write a loop script to traverse the input folder. The script calls the conversion tool for each PDF, saves the result to the output folder with the same name
.md, and writes the failed file name to the log. Readers who are not familiar with scripts can choose a desktop tool that supports batch selection of files and can output Markdown, but they must first confirm its output format. - Process pictures in a unified manner. Save the converted images to the
imagesfolder at the same level as Markdown, and confirm that the reference in Markdown is a relative path, that is, pointing to theimagesfolder, in the form ofimages/fig1.png. In this way, after the entire folder is moved, the pictures can still be displayed. - Check the failure log and rerun separately. The files in the log are usually encrypted PDFs, corrupted files or scans without OCR. Find out the reasons one by one and convert them individually after repairing them. Do not rerun the whole batch.
- Spot check the output results. Open several files with a text editor or Markdown preview, focusing on header levels, tables, and formulas. Files that need to be modified can be imported into the UniDoc web editor (app.unidoc.top) and adjusted piece by piece.
The PDF editor of the OmniDoc desktop client can export Word, Excel, and PowerPoint, but currently there is no batch export function listed for Markdown, so the batch solution in this article does not rely on it. If you need Markdown, you can first export the PDF to Word, and then use a common method to convert Word to Markdown. This will add an intermediate step and require additional verification.
Check each item after completion
After the batch conversion is completed, do not deliver it directly. Please go through the following check items.
| Check items | What do you think? | What if there's a problem? |
|---|---|---|
| Number of Fil | Compare the number of .md output and the number of PDF input | The quantity doesn't match. Check the failure log and rerun one by one. |
| Text integrity | Open several copies at random and compare them with the first and last pages of the original text. | Missing content is most common in encrypted files or scanned files without OCR. Go back to the corresponding steps to deal with. |
| Title level | Check whether # and ## are consistent with the original chapter structure. | Small range manual correction, large range can be replaced in batch with editor |
| Tables and formulas | Check to see if the table is misplaced and whether the formula symbol is missing | Complex forms can retain the picture version or be modified in comparison with the original PDF |
| Picture display | Open it in the preview and make sure the picture is displayed properly. | Check whether the images folder location and relative path are correct |
| Abnormal character | Search for common garbled characters, such as serial question marks or boxes | Check whether the source file is scanned and re-OCR if necessary |
Recognition errors can occur in both machine conversion and OCR, especially numbers, person names, and technical terms. For references, data and legal provisions, please check them one by one according to the original PDF.
# Core comparison
| Mode | An appropriate situation | What you need to pay attention to. |
|---|---|---|
| Online conversion website | Few documents and no confidential content | There is usually a file size and page limit, and the file is uploaded to the website |
| Desktop tool | Medium number of files that need to be processed offline | To confirm whether batch selection is supported, and whether the output is Markdown |
| Command line plus script | Large number of files, unified naming and directory structure | A certain basis of operation is required, and you should try it with a small number of files for the first time. |
# frequently asked questions (FAQ)
1. Search "pdf to markdown batch tools are free", how to choose free tools?
Look at four things: whether there is a limit on the size and number of pages of a single file, whether there is a watermark in the output, whether the file will be uploaded to the server, and whether the title, paragraph and table will be retained after conversion. For data with high privacy requirements, offline method is preferred.
2. Will the formula be lost after batch conversion?
Complex formulas may be converted into garbled codes or treated as pictures. It is recommended to try several documents with formula first, confirm the effect and then deal with them in batches, and keep the original PDF control for the key documents.
3. Can a long PDF be split into multiple Markdown?
Sure. It is a common practice to segment the content by first-level title or chapter, and the content can be saved by title location in the script. After splitting, check to see if the links between chapters and picture references are still available.
4. Can you upload dozens of PDF directly on the web page at a time?
Depending on the description of the specific service, many web pages support processing only one document at a time. OmniDoc currently does not list the feature of batch export of Markdown, so do not expect the web end to complete the whole batch conversion at once. It is recommended to process it in batches according to the process in this article.
5. How to edit the converted Markdown?
You can modify it directly with any text editor. If you want to edit in a web page, the UniDoc web page editor supports Markdown, you can open the file and adjust the title, paragraph and table, and then export to save.
# Summary
To convert PDF into Markdown in batches, the key is to first classify and unify the input and output directories, then run at one time with scripts or batch tools, and finally spot-check the results according to the checklist. OCR the scanned piece first, reference the picture with a relative path, and rerun the failed file separately, which can avoid most rework.


