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