I have a bat file that calls a vbscript that converts the encoding of a file. while running the code by setting the parth of the file it works fin, but when I am trying to pass more than one file as parameter i am getting the following error: microsoft vbscript runtime error :invalid or unqualified reference
You can see my batch script below run.cmd :
@Echo off
SET CHEMINDAT = C:\Users\myuser\Desktop\TRY\DATA_TY\
SET CHEMINTMP = C:\Users\myuser\Desktop\TRY\TMP\
echo %DATE% %TIME% Debut de traitement.
dir %CHEMINDAT%* /a:-d/b > %CHEMINTMP%-liste.txt 2
FOR /F "eol=; tokens=1 delims=, " %%i in (%CHEMINTMP%-liste.txt) do (
echo %%i > %CHEMINTMP%Fichier_en_cours.txt
echo %DATE% %TIME% Traitement du fichier : %%i
cscript //NoLogo C:\Users\myuser\Desktop\TRY\\Scripts\unix2dos_7.vbs %%i
)
pause
exit /b 1
Below you will fins my VBScript 'unix2dos_7.vbs':
Const adTypeBinary = 1
Const adTypeText = 2
Const adSaveCreateNotExist = 1
Const adSaveCreateOverWrite = 2
Const adWriteLine = 1
Const adReadLine = -2
Const adLF = 10
Const adCR = 13
Const adCRLF = -1
Set streamUTF8 = CreateObject("ADODB.Stream")
Set streamASCII = CreateObject("ADODB.Stream")
Dim args
set args = Wscript.arguments
strOutOne= args(0)
streamUTF8.Open
streamUTF8.Type = adTypeText
streamUTF8.LineSeparator = adCRLF
streamUTF8.Charset = "UTF-8"
streamUTF8.LoadFromFile strOutOne
streamASCII.Open
streamASCII.Type = adTypeText
streamASCII.LineSeparator = adCRLF
streamASCII.CharSet = "us-ascii"
Do Until streamUTF8.EOS
streamASCII.WriteText streamUTF8.ReadText(adReadLine), adWriteLine
Loop
streamASCII.SaveToFile "myfileConverted.txt", adSaveCreateOverWrite
I also want to replace the original file with the new one, instead of creating a new one 'myfileConverted.txt'. so that I don't have two times the same document
Can anyone pleas help?
Thanks in advance