Computing.Net > Forums > Programming > VBS help please

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBS help please

Reply to Message Icon

Name: ukits06
Date: May 12, 2006 at 03:01:22 Pacific
OS: XP 2600
CPU/Ram: P4 3.0
Product: IBM S51
Comment:

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.txt

Could 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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 12, 2006 at 03:19:56 Pacific
Reply:

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



0

Response Number 2
Name: jhunt303
Date: May 12, 2006 at 03:38:11 Pacific
Reply:

System.IO.File.Copy(SourceFileName, DestFileName)


0

Response Number 3
Name: ukits06
Date: May 12, 2006 at 05:24:10 Pacific
Reply:

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


0

Response Number 4
Name: SN
Date: May 12, 2006 at 09:08:33 Pacific
Reply:

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


0

Response Number 5
Name: tonysathre
Date: May 18, 2006 at 13:14:37 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: May 18, 2006 at 13:21:50 Pacific
Reply:

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


0

Response Number 7
Name: tonysathre
Date: May 18, 2006 at 13:35:06 Pacific
Reply:

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


0

Response Number 8
Name: Mechanix2Go
Date: May 18, 2006 at 13:39:34 Pacific
Reply:

Hi Tony,

Yes, it could.


If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBS help please

VB Help please www.computing.net/answers/programming/vb-help-please/9306.html

vb help club www.computing.net/answers/programming/vb-help-club/9453.html

VB help Please! www.computing.net/answers/programming/vb-help-please/7194.html