用于重命名用户APPDATA文件夹中文件的批处理文件

时间:2017-04-25 15:56:33

标签: batch-file

看来我们所有用户构建块* .dotx文件都已损坏。我需要为所有用户重命名这些文件,以便MS Word重新创建它们。这是我放在一起但它似乎不起作用。我希望它遍历每个用户appdata文件夹(存储在R:\ Usersfolders \ username中)并重命名这些文件,将OLD附加到文件名的末尾。任何帮助将不胜感激!

@echo off

for /F %Building Blocks.dotx% in(R:\UsersFolders\*username*\AppData\Roaming\Microsoft\Document Building Blocks\1033\15) do (rename "Building Blocks.dotx" "Building BlocksOLD.dotx")

for /F %Built-In Building Blocks.dotx% in (R:\UsersFolders\*username*\AppData\Roaming\Microsoft\Document Building Blocks\1033\15) do (rename "Built-In Building Blocks.dotx" "Built-In Building BlocksOLD.dotx")

pause

1 个答案:

答案 0 :(得分:0)

你正在使用一些非常错误的东西。

  • 您似乎猜测ren命令的语法。
  • 您不能在路径中使用通配符(最后一个元素除外)
  • 您的for /f %%a in ('dir /b /ad "R:\UsersFolders"') do ( echo ren "%%~fa\AppData\Roaming\Microsoft\Document Building Blocks\1033\15\Built-In Building Blocks.dotx" "Built-In Building BlocksOLD.dotx" ) 命令无法接收文件的完整路径

您的代码应该类似于:

def check(self, guess):
    #compares the guess to the correct answer
    print ("guess " + guess)
    correct = self.problems[self.counter].correct
    print ("correct " + correct)
    self.btnA.config(state='disabled')
    self.btnB.config(state='disabled')
    self.btnC.config(state='disabled')
    self.btnD.config(state='disabled')
    if guess == correct:
      #update ans
      if guess == "A":
         self.astatus["text"] = "✓"
      elif guess == "B":
         self.bstatus["text"] = "✓"
      elif guess == "C":
         self.cstatus["text"] = "✓" 
      else:
         self.dstatus["text"] = "✓"
      self.marks+=10

    else:
      if guess == "A":
         self.astatus["text"] = "x"
      elif guess == "B":
         self.bstatus["text"] = "x"
      elif guess == "C": 
         self.cstatus["text"] = "x"
      else:
         self.dstatus["text"] = "x"


      if correct == "A":
         self.btnA["fg"] = 'green'
      elif correct == "B":
         self.btnB["fg"] = 'green'
      elif correct == "C": 
         self.btnC["fg"] = 'green'
      else:
         self.btnD["fg"] = 'green'