I'm trying to save the output text file from this vbscript as ANSI instead of Unicode.
This is the simplified script:
Option Explicit
dim fso, obs, fol, spl, files, objFile, arr, file, ext, ex
Set fso = CreateObject("scripting.filesystemobject")
Set obs = CreateObject("shell.application")
Set fol = fso.GetFolder(".")
Set spl = obs.NameSpace(fol.Path)
Set files = fol.Files
set objFile = fso.openTextFile("test.txt" ,2 , true, false)
arr = Array("mp4")
For Each file In files
ext = fso.GetExtensionName(file.Name)
For Each ex In arr
If StrComp(ext,ex,1)=0 Then
objFile.writeline fol.Path & "\" & spl.GetDetailsOf(spl.ParseName(file.Name),0) & vbcrlf & spl.GetDetailsOf(spl.ParseName(file.Name),27) & vbcrlf & spl.GetDetailsOf(spl.ParseName(file.Name),28)
End If
Next
Next
objFile.Close
If I change:
set objFile = fso.openTextFile("test.txt" ,2 , true, false)
To:
set objFile = fso.openTextFile("test.txt" ,2 , true, true)
the script works, but saves the output as Unicode. If I keep the false the script gives me Invalid procedure call or argument. This is the part that is causing the error:
spl.GetDetailsOf(spl.ParseName(file.Name),28)
I have tried loads of other extended properties and they all work fine as ANSI. It just seems to be this one that is giving me problems. I have tried loads of different files and the result is the same. I don't know enough to fix this unfortunately, so I would be very greatful for any help.