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)
- Edited by ss4040 15 hours 19 minutes ago