Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm very new to VBS and I need help. I want to set up a script to copy a file from one drive to another and then rename the file to 'filename'-'date'.ext below is an example
copy file q:\test.txt -> p:\test\results.txt
rename p:\tests\results -> results010506.txtCould some one point me in the right direction, I’m happy to learn my self if people can advise what functions I need.
Many thanks
Dan

Hi Dan,
I dunno about VBS but in a batch it should be as simple as:
copy p:\source\oldname q:\dest\newname
=====================================
If at first you don't succeed, you're about average.M2

Guys,
Thanks for your help. I should probably explain my self a little better.
We have a script that deletes files older than 30 days on one of our drives. In turn this chucks out a log file which is extreamly useful to keep.
It would in all probability be easier to modify the script to instead of giving the file a set "filename.txt" use a file name tht incoporates the date that it was created and a indevidual file name.
However I think I would find this sort of this usefull elsewhere.
I have looked at using a batch file but I think it would be possible to do more with vbs in the long run? I could be wrong, for the moment I will look at:
"System.IO.File.Copy"Thanks to jhunt303 for the advise

You should check out MSDN's documentation for the FileSystemObject. Plenty of examples in there.
jhunt's example is how you would do this in VB.NET, not VBScript. VB.NET is much more powerful, but it's not so much a quick and dirty hack like most VBScript stuff is.
Good luck,
-SN

Can't you use the %DATE% variable.
The batch file would look like this:
@echo off
echo copying files...
copy p:\source\oldname q:\dest\newname-%date%
echo copy complete
pause
Fed up with Windows? Try Ubuntu Linux

Well...
Maybe. It depends on the date layout. If it contains illegal chars, it's a no-go.
If at first you don't succeed, you're about average.M2

If the output of the date was formatted with month/day/year couldn't another function in the batch file replace the / with another non-illegal character?
I'm sure you know how to do it, I'm not much of a scripter myself.
Fed up with Windows? Try Ubuntu Linux

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |