天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

StudyDo

天道酬勤,厚德载物,自强不息,求真务实,动脑动手,孜孜以求

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

I build a folder in gitee library.

I use picgo to help me upload the pics. At the same time, I want to make a copy for the blog files.

I used git pull command to help update the local file.

Meanwhile,I can directly add file into the local folder. And the below git command to upload it.

git add -A
git commit -m "add new pics"
git push

If we want to directly access the file, we can use the https://gitee.com/zhulinmails/git-images/raw/master/2021/ to concatenate with the local file name. The result is shown below.

https://gitee.com/zhulinmails/git-images/raw/master/2021/2021-08-02_165202.png

Result

The exploration give us a new way to do the picture library in Gitee.

If we concatenate the path by ourselves, it is very troublesome. Therefore I write a small python script to help to handle it. The performance is pretty good.

import os
import sys
import time

current_file_dir=os.path.dirname(os.path.abspath(__file__))
os.chdir(current_file_dir)

strBase="![{0}](https://gitee.com/zhulinmails/git-images/raw/master/2021/{1})"

exts=['.jpg','.png','.gif']

for root,dirs,files in os.walk("."):
    for filename in files:
        for ext in exts:
            if filename.endswith(ext):
                full_path=os.path.join(current_file_dir,filename)
                file_modify_time=os.stat(full_path).st_mtime
                if time.time()-file_modify_time<60*60*24:
                   print(strBase.format(filename,filename))

waitInput=input("请等待")

gitPythonGenerateScript.png

posted on 2021-08-03 14:55  三木人  阅读(66)  评论(0编辑  收藏  举报