简单的Windows批处理

学会写个简单的.bat吧

事件起因

边狱巴士游戏脚本时,Pyinstaller打包出来还是会缺很多文件,每次打包都要手动复制粘贴这么多文件,简直折磨死我,还不如写一个bat让电脑批处理算了

以该事件为例

待处理的文件

点击查看内容

简单统计一下,我需要

  • 复制
    “E:\Project\Python\Limbus-Scripts\assets”文件夹及里面的所有文件
    “E:\Project\Python\Limbus-Scripts\log”文件夹及里面的所有文件
    “E:\Project\Python\Limbus-Scripts\models”文件夹及里面的所有文件
    “E:\Project\Python\Limbus-Scripts\settings.ini”文件
    粘贴到
    “E:\Project\Python\Limbus-Scripts\dist\main_internal”文件夹;
  • 复制
    “E:\Project\Python\Limbus-Scripts\workbench\choices_dict.json”文件
    “E:\Project\Python\Limbus-Scripts\workbench\worklist.json”文件
    粘贴到
    “E:\Project\Python\Limbus-Scripts\dist\main_internal\workbench”文件夹;
  • 复制
    “E:\Project\Python\Limbus-Scripts\onnxruntime_providers_shared.dll”文件
    粘贴到
    “E:\Project\Python\Limbus-Scripts\dist\main_internal\onnxruntime\capi”文件夹;
  • 复制
    “D:\anaconda\envs\py310\Lib\site-packages\rapidocr_onnxruntime\models”文件夹及里面的所有文件
    “D:\anaconda\envs\py310\Lib\site-packages\rapidocr_onnxruntime\config.yaml”文件
    粘贴到
    “E:\Project\Python\Limbus-Scripts\dist\main_internal\rapidocr_onnxruntime”文件夹

- 2024.3.7更新 -


解决方法

点击查看内容

写一个pack.bat文件,打包完后双击运行即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@echo off

@REM 主目录的图片和记录和OCR模型和设置ini
set "source1=assets"
set "source2=log"
set "source3=models"
set "source4=settings.ini"

set "destination1=dist\main\_internal"

xcopy /s /i "%source1%" "%destination1%\%source1%"
xcopy /s /i "%source2%" "%destination1%\%source2%"
xcopy /s /i "%source3%" "%destination1%\%source3%"
copy /y "%source4%" "%destination1%"

@REM 工作区
set "source5=workbench\choices_dict.json"
set "source6=workbench\worklist.json"

set "destination2=dist\main\_internal\workbench\"

xcopy /s /i "%source5%" "%destination2%"
xcopy /s /i "%source6%" "%destination2%"

@REM OCR的一个警告dll
set "source7=onnxruntime_providers_shared.dll"
set "destination3=dist\main\_internal\onnxruntime\capi"

copy /y "%source7%" "%destination3%"

@REM OCR的依赖
if exist D:\anaconda (
set "anaconda_folder=D:\anaconda"
) else (
set "anaconda_folder=D:\Anaconda3"
)

set "source8=%anaconda_folder%\envs\py310\Lib\site-packages\rapidocr_onnxruntime\models"
set "source9=%anaconda_folder%\envs\py310\Lib\site-packages\rapidocr_onnxruntime\config.yaml"
set "destination4=dist\main\_internal\rapidocr_onnxruntime"

xcopy /s /i "%source8%" "%destination4%\models"
copy /y "%source9%" "%destination4%"

pause

- 2024.3.7更新 -