Skip to content

Commit

Permalink
🚲增加新建文件方式
Browse files Browse the repository at this point in the history
  • Loading branch information
linyisonger committed Jun 12, 2024
1 parent a5c951f commit 219005e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ git add examples.txt
新建示例文件
```shell
echo '' > "058.tesseract.js 文字识别.html"
# 或者
python .\build\new.py 思绪万千
```

#### 示例截图
Expand Down
23 changes: 23 additions & 0 deletions build/new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 自动编号
import os
import shutil
import sys
if __name__ == '__main__':
args = sys.argv[1:]

index = 1
useNumList = []

for file in os.listdir(os.getcwd()):
if file.endswith(".html"):
if file.split(".")[0].isdigit():
useNumList.append(int(file.split(".")[0]))

while index in useNumList:
index+=1

index = f'{index}'.zfill(3)
newFileName =f'{index}.{args[0]}.html'
shutil.copy(os.path.join(os.getcwd(), 'build', 'template.html'),os.path.join(os.getcwd(), newFileName))

print('新建文件成功', newFileName)
15 changes: 15 additions & 0 deletions build/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/global.css">
</head>

<body>

</body>

</html>

0 comments on commit 219005e

Please sign in to comment.