Rename files with VBS and external textfile

Joined
Jul 11, 2006
Messages
1
Reaction score
0
Hello everyone,

Someone asked me if I can come up with a script to rename +/- 18.000 files.
Via a batchscript it will be too difficult for me (VBS also, that's why I come here for help!), so I hope someone can help me out here:

I got an external text-file that looks like this:

V-WT-VXX-244-c C:\DRAWING\XXX\00000025.DWG
V-WT-VXX-243-d C:\DRAWING\XXX\00000026.DWG
V-WT-VXX-230-d C:\DRAWING\XXX\00000027.DWG

The left column contains the new filename without extension, the right column contains the full path to the file and the current filename.

I want the script too look into the directory (and subdirectory's) and replace the old filename with the new filename, but leaving the extension the same.

Can someone help me out with this, for me, real big problem?


On a Microsoft website I found this script, that looks a bit as something that can do the job for me, but it's not working, also because I dont have any VB skills (but I am a quick learner).


Const ForReading = 1

strComputer = "."
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\TEKENING\lijst.txt", ForReading)

Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrParts = Split(strLine, ",")
strFile = "C:\\TEKENING\\" & arrParts(0)
Set colItems = objWMIService.ExecQuery _
("Select * From CIM_Datafile Where Name = '" & strFile & "'")
For Each objItem in colItems
strNewName = "C:\TEKENING\*" & arrParts(1)
objItem.Rename strNewName
Next
Loop

objFile.Close



Regards,

Molski
 
Back
Top