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
 
moonhkt  
View profile  
 More options Oct 28 2009, 2:59 pm
Newsgroups: microsoft.public.scripting.vbscript
From: moonhkt <moon...@gmail.com>
Date: Wed, 28 Oct 2009 07:59:31 -0700 (PDT)
Local: Wed, Oct 28 2009 2:59 pm
Subject: Re: Renaming file as weekdays...
On Oct 28, 3:58 pm, Jake <jak...@gmail.com> wrote:

> 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

you can using weekday(),retrun 1,2,3,.. then rename to Weekday.

Option Explicit
'~~ 2009/09/27 renname to yyymmdd*.jpg
'~~ 2007/08/28
'~~ Backup file *.nsf file to *_yyyymmdd.nsf
'~~ whs %shell%\rename_scanimage.vbs
Dim wdate
Dim oShell
Dim source , target, tmpfile,tmpfile1
Dim fso
dim WshShell, intButton,ObjExec,folder,file
dim cnt

Set fso = CreateObject("Scripting.FileSystemObject")
'~~ wDate = Year(Now) & Right("00" & Month(Now), 2) & Right("00" & Day
(Now), 2)
cnt = 0
Set WshShell = Wscript.CreateObject("Wscript.Shell")
        set folder = fso.GetFolder (".")  '~~ Currenty Directory
        for each file in folder.Files
                if fso.GetExtensionName (file.Path) = "jpg" then
                        if left(file.name,7) = "Picture" then
                                cnt = cnt + 1
                                '~~~tmpfile = wDate & "_" & cnt & ".jpg"
                                WScript.Echo file.name & " " & tmpfile
                                tmpfile1 = year(file.DateLastModified) & _
                                   right("00" & Month(file.DateLastModified),2) & _
                                   right("00" & day(file.DateLastModified),2) & "_" & _
                                   right("000" & cnt,3) & ".jpg"
                                WSCript.echo  tmpfile1
                                '~~ if file name existing

                                '~~ Start rename
                                fso.movefile file.name , tmpfile1
                        end if

                end if
        next

Set oShell = Nothing
Set folder = Nothing
Set fso = nothing
set WshShell = nothing


    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