renaming workbooks

Hi,

I've about 60 workbooks in a directory  ;- C:\Reports\

Each workbook is a persons name and I need to change this
  instead of

Salesperson1.xls,
Salesperson2.xls,
Salesperson3.xls

etc,

I need to put  the words Report Document in  front of each workbook

so the name of each workbook is now

Report Document  Salesperson1.xls
Report Document  Salesperson2.xls
Report Document  Salesperson3.xls

etc.
Any help would be much appreciated.

Regards,

linnanda

LINNANDAAsked:
Who is Participating?
 
William ElliottConnect With a Mentor Sr Tech GuruCommented:
oh...
change
 fso.CopyFile
to
 fso.moveFile
0
 
William ElliottSr Tech GuruCommented:

strfolder = "C:\reports\"
 
set fso = createobject("Scripting.FilesystemObject")
set myfolder = fso.GetFolder(strfolder)
 
for each file in myfolder.files
 
   if lcase(right(file.name, 3)) = "xls" then
     fso.CopyFile strfolder & file.name , strfolder & "Report Document " & file.name
   end if  
next

Open in new window

0
 
William ElliottSr Tech GuruCommented:
save the above script in notepad.,. cal it "report_rename.vbs" and double click on it.
0
 
LINNANDAAuthor Commented:
Thanks weellio, that worked fine however then original files are still present, is there any way to delete the orginal files
0
 
LINNANDAAuthor Commented:
Thanks weellio, that worked fine.
0
All Courses

From novice to tech pro — start learning today.