January 5, 2005 at 8:16 am
This is a VB or other scripting question, not SQL: need a script that will allow me to rename files that end with "OK" to the name without the "OK". For example, an ASCII file named ABC.0001OK, I want to rename to ABC.0001. I would want to rename all files in a given folder like this.
ABC.0001OK to ABC.0001, ABC.0002OK to ABC.0002, etc.
Does anyone have a script that they would like to share?
January 5, 2005 at 10:25 am
Option Explicit
'*
Const cVBS = "renamer.vbs"
Const cPRE = "OK"
Const cEXT = "XML"
Const cFOL = "c:\NACHA\"
'*
Dim strFIL
Dim strGFI
Dim intMOV
intMOV = 0
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objGFO
Set objGFO = objFSO.GetFolder(cFOL)
Dim objGFI
Set objGFI = objGFO.Files
For Each strGFI in objGFI
strFIL = strGFI.Name
If Instr(strFIL,cPRE) >= 1 Then
intMOV = intMOV + 1
objFSO.MoveFile strGFI, Replace(strGFI,"OK","")
End If
Next
'*
Set objGFI = Nothing
Set objGFO = Nothing
Set objFSO = Nothing
'*
MsgBox intMOV & " files renamed",vbInformation,cVBS
Modify according to your needs.
Thanks,
Ganesh
January 5, 2005 at 10:28 am
You can use this to limit the file extension
And UCase(Right(strFIL,Len(cEXT))) = cEXT Then
January 5, 2005 at 10:59 am
This is perfect. Thanks ever so much.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply