# 将md文档中的本地照片批量上传到图床并修改文档中的链接 **Repository Path**: hydrogenion/md-image-auto-upload ## Basic Information - **Project Name**: 将md文档中的本地照片批量上传到图床并修改文档中的链接 - **Description**: 将md文档中的本地图片批量上传到图床 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 1 - **Created**: 2022-01-05 - **Last Updated**: 2022-12-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Convert the local picture format in the MD document and automatically upload it to the drawing bed ### Introduction Upload all local pictures in the MD document to the drawing bed and change the path in the 'MD' document Support batch processing of all MD files in a folder (automatic processing, including subfolders) There are two ways - Upload directly to the drawing bed - Send the pictures to the local git warehouse, and push the local warehouse to the remote warehouse after processing (suitable for the situation where `Gitee` or `GitHub` will be used as the drawing bed) ### The processing effect is shown in the figure below - Contents in original document ![image-20220106003131045](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106003131045.png) ![image-20220106002918351](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106002918351.png) - Content after processing ![image-20220106003000687](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106003000687.png) ![image-20220106003017169](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106003017169.png) - The effect is shown in the figure below ![image-20220106003748620](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106003748620.png) - File list after processe The file name is its `path + the original file name` (excluding the drive letter) ![image-20220106003849761](https://gitee.com/hydrogenion/drawing-bed/raw/master/test/image-20220106003849761.png) ### Instructions for use Use the following command to pull the project down locally ```git git clone git clone https://gitee.com/hydrogenion/md-image-auto-upload.git ``` Modify the following path as the local corresponding path ```java // 需要处理的文件所在文件夹,自动检索子文件夹 public static String basePath = "D:\\大三上"; // 非直接上传模式照片存储路径(本地git仓库的路径) public static String imgStorePath = "D:\\drawing-bed-two\\img\\"; // 非直接上传模式照片上传后访问的前缀 public static String imgUploadPrefix = "https://gitee.com/hydrogenion/drawing-bed-two/raw/master/img/"; // 处理后的文件输出路径 public static String fileStorePath = "D:\\blogs\\笔记\\笔记汇总\\"; // 上传文件的命令,需要再拼接文件路径,这里使用的picGo-core,也可以使用其他的上传工具 public static String uploadCommand = "cmd /d/s/c C:\\Users\\tux\\AppData\\Roaming\\Typora\\picgo\\win64\\picgo.exe u "; // 需要检测的图片后缀 public static String[] imgSuffix = {".png", "jpg", "jpeg"}; ``` >For the configuration method of picgo core, please refer to [typora + picgo core insert picture automatic upload]( https://blog.csdn.net/jaymie1023/article/details/105361168/ ) > The uploaded photos are prefixed with other parts except the file name - If it is mode 1, the program can be previewed in the generated file after running - If it is mode 2, you need to enter the local git warehouse to push before you can preview it normally in the generated file