Hi
I have a .CSV file with an existing name column and a new name column.
E.G. 3145.pdf, Item 3145.pdf
I want to look at the first column (3145.pdf) find that file in a given directory (c:\temp) and then rename it to the second column (Item 3145.pdf) and then move to the next column until all files in the folder have been renamed.
I came across what I believe is the solution in a VB script only I don’t know how to run the script so I thought I could do similar from within VB6.
I have a .CSV file with an existing name column and a new name column.
E.G. 3145.pdf, Item 3145.pdf
I want to look at the first column (3145.pdf) find that file in a given directory (c:\temp) and then rename it to the second column (Item 3145.pdf) and then move to the next column until all files in the folder have been renamed.
I came across what I believe is the solution in a VB script only I don’t know how to run the script so I thought I could do similar from within VB6.
Code:
' VBScript source code
Const ForReading = 1
strComputer = "."
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\TEMP\PDF_338-Series_Numbers_from_Alchemy\338-Series_Alchemy_Metadata.txt.csv", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrParts = Split(strLine, ",")
strFile = "C:\\TEMP\PDF_338-Series_Numbers_from_Alchemy\\" & arrParts(0)
Set colItems = objWMIService.ExecQuery _
("Select * From CIM_Datafile Where Name = '" & strFile & "'")
For Each objItem in colItems
strNewName = "C:\TEMP\PDF_338-Series_Numbers_from_Alchemy\" & arrParts(1)
objItem.Rename strNewName
Next
Loop
objFile.Close