Web Images News Groups Scholar Blogs Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Renaming file as weekdays...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
Jake  
View profile  
 More options Oct 28, 7:58 am
Newsgroups: microsoft.public.scripting.vbscript
From: Jake <jak...@gmail.com>
Date: Wed, 28 Oct 2009 08:58:46 +0100
Local: Wed, Oct 28 2009 7:58 am
Subject: Renaming file as weekdays...
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


    Reply    Reply to author    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.
moonhkt  
View profile  
 More options Oct 28, 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:

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


    Reply    Reply to author    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.
Pegasus [MVP]  
View profile  
 More options Oct 28, 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...

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

    Reply    Reply to author    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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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