From: PAkerly on
Hello, How would I write vb script to do this?...seems simple but I
have no idea.

I have files in the directory C:\MyFiles

they are named MYFiles101509.awq MyFiles111709.awq

I want to rename them to OctFiles0001.xls and NovFiles0001.xls

is there a way to look through files like look for MYFiles01* and
rename that way?

thanks.
From: mayayana on
If you don't have the WSH help file you should
download it and read up about the VBS methods
so that you'll at least "have some idea". :)

String operations you might need include
Mid, Instr, Left, Right.

> Hello, How would I write vb script to do this?...seems simple but I
> have no idea.
>
> I have files in the directory C:\MyFiles
>
> they are named MYFiles101509.awq MyFiles111709.awq
>
> I want to rename them to OctFiles0001.xls and NovFiles0001.xls
>
> is there a way to look through files like look for MYFiles01* and
> rename that way?
>
> thanks.


From: "Dave "Crash" Dummy" on
PAkerly wrote:
> Hello, How would I write vb script to do this?...seems simple but I
> have no idea.
>
> I have files in the directory C:\MyFiles
>
> they are named MYFiles101509.awq MyFiles111709.awq
>
> I want to rename them to OctFiles0001.xls and NovFiles0001.xls
>
> is there a way to look through files like look for MYFiles01* and
> rename that way?

Yes, but your details are a little confusing. I am assuming the filename
contains a date, like October 15, 2009 for MyFiles101509.awq. If so, is
there only one file per month, or more than one file per month that you
want named in order, 0001, 0002, etc.? If the latter, why not just use
the date, like OctFiles15.xls? That would make life a LOT simpler. This
will do that:

'---------------------rename.vbs---------------------
dim mo(12)
mo(1)="JanFiles"
mo(2)="FebFiles"
mo(3)="MarFiles"
mo(4)="AprFiles"
mo(5)="MayFiles"
mo(6)="JunFiles"
mo(7)="JulFiles"
mo(8)="AugFiles"
mo(9)="SepFiles"
mo(10)="OctFiles"
mo(11)="NovFiles"
mo(12)="DecFiles"

set fso=CreateObject("Scripting.FileSystemObject")
set folder=fso.getFolder("C:\MyFiles")
for each file in folder.files
if left(lcase(file.name),7)="myfiles" then
file.name=mo(mid(file.name,8,2)) & mid(file.name,10,2) & ".xls"
end if
next
'----------------------------------------------------------------------
--
Crash

English is not my native tongue; I'm an American.