Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Renaming file as weekdays...
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pegasus [MVP]  
View profile  
 More options Oct 28 2009, 4:38 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Wed, 28 Oct 2009 17:38:38 +0100
Local: Wed, Oct 28 2009 4:38 pm
Subject: Re: Renaming file as weekdays...

"Jake" <jak...@gmail.com> wrote in message

news:eoiC7R6VKHA.4484@TK2MSFTNGP02.phx.gbl...

> Hi,

> I have a file called C:\MyDir\MyFile.dat which is copied to this folder
> automatically each night.

> I need to keep a copy of this file for the seven last days.  Hence I need
> to have the file renamed to the day of week, overwriting the old
> filenames.  The result should be a set of files Thursday.dat, Friday.dat,
> Saturday.dat... etc in C:\MyDir.

> How would I do this in vbscript?  I'm realtively new to this, but I want
> to learn :-)

> thanks anyone

> jake

Here you go. I strongly recommend that you download the helpfile
script56.chm from the Microsoft site. It contains examples for all the basic
functions you need.
sOldName = "d:\temp\MyFile.dat"
sNewName = "d:\temp\" & WeekDayName(WeekDay(Date)) & ".dat"
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not oFSO.FileExists(sOldName) Then
  MsgBox "Cannot find " & sOldName
  WScript.Quit
End If
If oFSO.FileExists(sNewName) then oFSO.DeleteFile(sNewName)
oFSO.MoveFile sOldName, sNewName

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google