From 2f955f222be1f212aff26ceb59033155d4685f94 Mon Sep 17 00:00:00 2001 From: mengzonefire <44224240+mengzonefire@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:03:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8win32api=E6=9B=BF=E4=BB=A3cmd?= =?UTF-8?q?=E4=BB=A5=E9=81=BF=E5=85=8D=E8=BF=90=E8=A1=8C=E6=97=B6=E9=97=AA?= =?UTF-8?q?=E7=8E=B0=E6=8E=A7=E5=88=B6=E5=8F=B0=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ renamer.py | 15 +++++++++------ requirements.txt | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a73abf4..52058d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.vscode +.history + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/renamer.py b/renamer.py index 854a7e6..5ad3495 100644 --- a/renamer.py +++ b/renamer.py @@ -11,6 +11,7 @@ import stat +import win32api # Windows 系统的保留字符 # https://docs.microsoft.com/zh-cn/windows/win32/fileio/naming-a-file # <(小于) @@ -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: diff --git a/requirements.txt b/requirements.txt index cc89ed1..9d0e91c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,4 @@ requests==2.28.1 six==1.16.0 urllib3==1.26.7 wxPython==4.1.1 +pywin32==304