This is a multi-part message in MIME format.
------=_NextPart_000_000E_01C4AA6D.E3ECA330
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Hi,
The following script is supposed to rename all files start with sg and =
with extension .dat, it will remove the prefix sg from the file name. eg =
: sgtestfile.dat --> testfile.dat.
However, it is not working as expected, it returns error:
"G:\Script\Test\rename.vbs(1, 19) Microsoft VBScript compilation error: =
Expected end of statement Exit code: 1 , 0001h"
Dim strPrefix As String, strExtension As String, strPath As String=20
Dim strFilePattern As String, strstrOldName As String, strNewName As =
String=20
=20
strPrefix =3D "SG"=20
strExtension =3D "DAT"=20
strPath =3D "G:\Script\Test\"=20
=20
strFilePattern =3D strPath & strPrefix & "*." & strExtension=20
=20
Dim strFileFinder As String=20
strFileFinder =3D Dir(strFilePattern)=20
=20
Do Until strFileFinder =3D ""=20
strOldName =3D strPath & strFileFinder=20
strNewName =3D strPath & Right(strFileFinder, Len(strFileFinder) =
- Len(strPrefix))=20
Name strOldName As strNewName=20
strFileFinder =3D Dir=20
Loop=20
Can anyone help, I feel that the line "strFileFinder =3D =
Dir(strFilePattern)" is having problem.
Thanks
Frank
------=_NextPart_000_000E_01C4AA6D.E3ECA330
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>The following script is supposed =
to rename all=20
files start with sg and with extension .dat, it will remove the prefix =
sg from=20
the file name. eg : sgtestfile.dat --> =
testfile.dat.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> However, it is not working as =
expected, it=20
returns error:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"G:\Script\Test\rename.vbs(1, 19) =
Microsoft=20
VBScript compilation error: Expected end of statement </FONT><FONT =
face=3DArial=20
size=3D2>Exit code: 1 , 0001h"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> Dim strPrefix As =
String,=20
strExtension As String, strPath As String <BR> Dim=20
strFilePattern As String, strstrOldName As String, strNewName As String=20
<BR> <BR> strPrefix =3D "SG"=20
<BR> strExtension =3D "DAT" <BR> =
strPath =3D=20
"G:\Script\Test\" <BR> <BR> =20
strFilePattern =3D strPath & strPrefix & "*." & strExtension =
<BR> <BR> Dim strFileFinder As =
String=20
<BR> strFileFinder =3D Dir(strFilePattern)=20
<BR> <BR> Do Until strFileFinder =3D =
""=20
<BR> strOldName =3D strPath =
&=20
strFileFinder <BR> strNewName =
=3D=20
strPath & Right(strFileFinder, Len(strFileFinder) - Len(strPrefix))=20
<BR> Name strOldName As =
strNewName=20
<BR> strFileFinder =3D Dir=20
<BR> Loop <BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Can anyone help, I feel that the=20
line "strFileFinder =3D Dir(strFilePattern)" is having =
problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Frank</DIV>
<DIV><BR></DIV></FONT></BODY></HTML>
------=_NextPart_000_000E_01C4AA6D.E3ECA330--