LearnScript
Programmer
Hi All,
I am new to this group and this is my first post. I need to write a vb script and I did not write any scripts before. Here is my problem. I have a folder A which contains .wav files. I need to move to Folder B and rename all the files. For example, I have abc_companyname.wav files in folder A then I have to construct a new name to rename.
example:
folder A : AbcFarm10152011_01.wav
if filename consists of Farm then construct a new name like below and rename.
folder B : clientname_vendorname_Farm_FT_FC_AID_date_CallID_.wav
Below is my code. I am doing something wrong which I couldn't figure out.
Dim fso,f
dim clientname , Vendor, code, FT, FC, AID, CallDate, CallID, FileType
Set fso=CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Docs\abc\queue\Source")
clientname= "abc"
Vendor= "xyz"
AID= "2222222"
CallDate = Date
FileType = "wav"
CallID = 000000
For Each file In f.Files
If InStr(file.Name,"Farm")>0 Then
code = "Farm_CT"
FT = "XYZ"
FC = "ABCXYZ"
CallID = CallID +1
newName = clientname & "_" & vendor & "_" & code & "_" & FT & "_" & FC & "_" & AID & "_" & CallDate & "_" & CallID & "_" & FileType
fso.MoveFile file.Name , "C:\Docs\abc\queue\Target\newName"
End If
Next
Set f = Nothing
Set fso = Nothing
I am getting file not found error. I didn't see any rename function in vb script. To use replace function I need to change the entire file name not a substring of it. I am doing something wrong at fso.MoveFile area. Any help would greatly appreciated.
I am new to this group and this is my first post. I need to write a vb script and I did not write any scripts before. Here is my problem. I have a folder A which contains .wav files. I need to move to Folder B and rename all the files. For example, I have abc_companyname.wav files in folder A then I have to construct a new name to rename.
example:
folder A : AbcFarm10152011_01.wav
if filename consists of Farm then construct a new name like below and rename.
folder B : clientname_vendorname_Farm_FT_FC_AID_date_CallID_.wav
Below is my code. I am doing something wrong which I couldn't figure out.
Dim fso,f
dim clientname , Vendor, code, FT, FC, AID, CallDate, CallID, FileType
Set fso=CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\Docs\abc\queue\Source")
clientname= "abc"
Vendor= "xyz"
AID= "2222222"
CallDate = Date
FileType = "wav"
CallID = 000000
For Each file In f.Files
If InStr(file.Name,"Farm")>0 Then
code = "Farm_CT"
FT = "XYZ"
FC = "ABCXYZ"
CallID = CallID +1
newName = clientname & "_" & vendor & "_" & code & "_" & FT & "_" & FC & "_" & AID & "_" & CallDate & "_" & CallID & "_" & FileType
fso.MoveFile file.Name , "C:\Docs\abc\queue\Target\newName"
End If
Next
Set f = Nothing
Set fso = Nothing
I am getting file not found error. I didn't see any rename function in vb script. To use replace function I need to change the entire file name not a substring of it. I am doing something wrong at fso.MoveFile area. Any help would greatly appreciated.