Skip to content

Commit

Permalink
Merge pull request #13 from mengzonefire/main
Browse files Browse the repository at this point in the history
使用win32api替代cmd以避免运行时闪现控制台窗口
  • Loading branch information
yodhcn authored Jan 26, 2023
2 parents 4162e51 + 2f955f2 commit b363130
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vscode
.history

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
15 changes: 9 additions & 6 deletions renamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import stat

import win32api
# Windows 系统的保留字符
# https://docs.microsoft.com/zh-cn/windows/win32/fileio/naming-a-file
# <(小于)
Expand Down Expand Up @@ -198,12 +199,14 @@ def changeIcon(self, rjcode: str, cover_url: str, icon_dir: str):
inifile.close()

# 隐藏 desktop.ini 文件 & .ico 文件
cmd1 = icon_dir[0:2]
cmd2 = "cd " + '\"' + icon_dir + '\"'
cmd3 = "attrib +h +s " + 'desktop.ini'
cmd4 = "attrib +h +s " + icon_name
cmd = cmd1 + " & " + cmd2 + " & " + cmd3 + " & " + cmd4
os.system(cmd) # 运行 cmd
win32api.SetFileAttributes(str(ini_file_path), 38)
win32api.SetFileAttributes(os.path.join(icon_dir, icon_name), 38)
# cmd1 = icon_dir[0:2]
# cmd2 = "cd " + '\"' + icon_dir + '\"'
# cmd3 = "attrib +h +s " + 'desktop.ini'
# cmd4 = "attrib +h +s " + icon_name
# cmd = cmd1 + " & " + cmd2 + " & " + cmd3 + " & " + cmd4
# os.system(cmd) # 运行 cmd
Renamer.logger.info(f'[{rjcode}] -> 修改封面成功:"{icon_name}"')

if self.__remove_jpg_file:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ requests==2.28.1
six==1.16.0
urllib3==1.26.7
wxPython==4.1.1
pywin32==304

0 comments on commit b363130

Please sign in to comment.