Skip to content

Commit

Permalink
Revert "避免重复执行 cmd"
Browse files Browse the repository at this point in the history
This reverts commit ae48d55.
  • Loading branch information
yodhcn committed Dec 21, 2022
1 parent ae48d55 commit 90dd2f9
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions renamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,27 @@ def rename(self, root_path: str):
def changeIcon(self, rjcode: str, cover_url: str, icon_dir: str):
os.chmod(icon_dir, stat.S_IREAD)
icon_name, jpg_name = self.__scraper.scrape_icon(rjcode, cover_url, icon_dir)
icon_path = os.path.join(icon_dir, icon_name)

if not os.path.exists(icon_path):
# 编写 desktop.ini
iniline1 = "[.ShellClassInfo]"
iniline2 = "IconResource=" + "\"" + icon_name + "\"" + ",0"
iniline3 = "[ViewState]" + "\n" + "Mode=" + "\n" + "Vid=" + "\n" + "FolderType=StorageProviderGeneric"
iniline = iniline1 + "\n" + iniline2 + "\n" + iniline3

# 写入 desktop.ini
inifile_path = Path(os.path.join(icon_dir, "desktop.ini"))
inifile_path.unlink(missing_ok=True) # 删除旧的 .ini 文件
with open(inifile_path, "w", encoding='utf-8') as inifile:
inifile.write(iniline)
inifile.close()

# 编写 cmd
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

# 编写 desktop.ini
iniline1 = "[.ShellClassInfo]"
iniline2 = "IconResource=" + "\"" + icon_name + "\"" + ",0"
iniline3 = "[ViewState]" + "\n" + "Mode=" + "\n" + "Vid=" + "\n" + "FolderType=StorageProviderGeneric"
iniline = iniline1 + "\n" + iniline2 + "\n" + iniline3

# 写入 desktop.ini
inifile_path = Path(os.path.join(icon_dir, "desktop.ini"))
inifile_path.unlink(missing_ok=True) # 删除旧的 .ini 文件
with open(inifile_path, "w", encoding='utf-8') as inifile:
inifile.write(iniline)
inifile.close()

# 编写 cmd
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

if self.__remove_jpg_file:
# 删除 .jpg 文件
Expand Down

0 comments on commit 90dd2f9

Please sign in to comment.