Haleydu / Cimoc

漫画阅读器
GNU General Public License v3.0
2.88k stars 231 forks source link

本地导入问题 #330

Open XI-ryimi opened 8 months ago

XI-ryimi commented 8 months ago

希望本地导入时能识别二级目录名称,自动生成分卷文件,并使用第一个文件夹中的0001.jpg作为封面 image

1115501230 commented 8 months ago

已经收到您发送的材料,如果未备注清楚的文件,将不会被使用!若未备注清楚请备注好发过来。感谢您的阅读。

XI-ryimi commented 8 months ago

我写了一个bat程序,将它放在单个漫画的目录下运行,分话文件夹应该命名成四位数的序列 默认生成20话的索引

@echo off
chcp 65001 > nul
setlocal enabledelayedexpansion

rem 创建四位数的文件夹(0001到0020)
for /l %%i in (1, 1, 20) do (
    set "folder=00000%%i"
    md "!folder:~-4!"
)

rem 生成index.cdif文件并保存到相应的文件夹中
for /l %%i in (1, 1, 20) do (
    set "folder=00000%%i"
    set "folder=!folder:~-4!"
    set "filename=!folder!\index.cdif"
    echo cimoc{"version":"1","type":"chapter","title":"%%i话","path":"!folder!"} > "!filename!"
)

rem 生成总的index.cdif文件
set "cid="
set "list="
for /l %%i in (1, 1, 20) do (
    set /a "rand=!random! %% 90000 + 10000"
    if not defined cid set "cid=!rand!"

    set "folder=00000%%i"
    set "folder=!folder:~-4!"
    set "list=!list!{"title":"%%i话","path":"!folder!"},"
)

set "list=!list:~0,-1!"
set "title=%~n0"
set "filename=index.cdif"
echo cimoc{"version":"1","type":"comic","source":1,"cid":"!cid!","title":"!title!","cover":"0001.jpg","list":[!list!]} > "!filename!"

rem 删除不包含图片的文件夹
for /d %%d in (*) do (
    if exist "%%d\0001.jpg" (
        echo "%%d\0001.jpg" exists
    ) else (
        echo "%%d" does not contain an image file. Deleting folder...
        rd /s /q "%%d"
    )
)

echo Index files created successfully.

pause