MS Word重命名脚本帮助 [英] MS Word renaming script help

查看:175
本文介绍了MS Word重命名脚本帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,正在寻找这个脚本的一些帮助:



设置objFSO = CreateObject(" Scripting .FileSystemObject")

设置objFolder = objFSO.GetFolder(" C:\ redamedocs")



设置objWord = CreateObject(" ; Word.Application")



对于objFolder.Files中的每个strFile

    arrNames = Split(strFile.Name,"。")

   如果arrNames(1)=" doc"然后

       设置objDoc = objWord.Documents.Open(strFile.Path)

       设置objRange = objDoc.Range(0,20)

        strNewName =" C:\ redamedocs \" &安培; objRange.Text& " .doc"

        objDoc.Close

        Wscript.Sleep 3000

        objFSO.MoveFile strFile.Path,strNewName

   结束如果

下一个



objWord.Quit



收到错误消息: 


缺少开头'('关键字后''为'。'
在C:\\\ scripts \ docscript2。 ps1:6 char:5

+ For <<<< objFolder.Files中的每个strFile

   + CategoryInfo      :ParserError:(OpenParenToken:TokenId)[],ParentContainsErrorRecordException

   + FullyQualifiedErrorId:MissingOpenParenthesisAfterKeyword



基本上,我正在尝试让脚本打开文件夹中的文件,查找前20个字符,然后重命名该文件,然后转到文件夹中的下一个文件/ do对于该文件夹中的所有文件。 感谢您的帮助。
 (这是一个PowerShell脚本,在Win 7 cpu上运行。  powershell 2.0)


解决方案



基本上,我正在尝试让脚本打开文件夹中的文件,查找前20个字符,然后重命名文件然后转到文件夹中的下一个文件/为该文件夹中的所有文件执行该操作。 &NBSP;谢谢你的帮助。
  (这是一个PowerShell脚本, 在Win 7 cpu上运行。  powershell 2.0)






只是要指出,你发布的不是PowerShell,而是VBScript。 尝试将脚本文件重命名为.vbs,以便它可以在wscript / cscript下运行,而不是尝试在Powershell中运行它。 


Hello,  looking for a bit of assistance with this script:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\renamedocs")

Set objWord = CreateObject("Word.Application")

For Each strFile in objFolder.Files
    arrNames = Split(strFile.Name, ".")
    If arrNames(1) = "doc" Then
        Set objDoc = objWord.Documents.Open(strFile.Path)
        Set objRange = objDoc.Range(0,20)
        strNewName = "C:\renamedocs\" & objRange.Text & ".doc"
        objDoc.Close
        Wscript.Sleep 3000
        objFSO.MoveFile strFile.Path, strNewName
    End If
Next

objWord.Quit

getting an error that says:  

Missing opening '(' after keyword 'for'.
At C:\scripts\docscript2.ps1:6 char:5
+ For  <<<< Each strFile in objFolder.Files
    + CategoryInfo          : ParserError: (OpenParenToken:TokenId) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword

basically,  i'm trying to have the script open the files in a folder, look for the first 20 char, then rename the file that and then go on to the next file in the folder/do that for all the files in that folder.   Thank you for any assistance.   (this is a powershell script,  run on Win 7 cpu.   powershell 2.0)

解决方案

basically,  i'm trying to have the script open the files in a folder, look for the first 20 char, then rename the file that and then go on to the next file in the folder/do that for all the files in that folder.   Thank you for any assistance.   (this is a powershell script,  run on Win 7 cpu.   powershell 2.0)


Just to point out, what you posted is not PowerShell, but VBScript.  Try renaming the script file to .vbs so it will run under wscript/cscript instead of trying to run it in Powershell. 


这篇关于MS Word重命名脚本帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆