Filename with date modified appended to filename  
Author Message
Techman121





PostPosted: Fri Nov 04 14:42:03 CST 2005 Top

VB Scripts >> Filename with date modified appended to filename need to find a way to change filenames that relect the filename and
the date modified. I have found numerous ways to get the current date
and time appended to the filename but nothing with date modified. I
have users that need to have this in the filename and I am in search of

some help in this matter. Example is a file named test.txt with a date

modified 1/31/2005. I would like the filename to be test
(1/31/2005).txt. Thanks in advance ...

Visual Studio24  
 
 
ESP





PostPosted: Fri Nov 04 14:42:03 CST 2005 Top

VB Scripts >> Filename with date modified appended to filename
I think what you are looking for is:
"Date last saved: " & objDocument.DateLastSaved

Reference here
http://www.microsoft.com/technet/scriptcenter/scripts/storage/files/stfivb31.mspx


ESP




"Guido" wrote:

> need to find a way to change filenames that relect the filename and
> the date modified. I have found numerous ways to get the current date
> and time appended to the filename but nothing with date modified. I
> have users that need to have this in the filename and I am in search of
>
> some help in this matter. Example is a file named test.txt with a date
>
> modified 1/31/2005. I would like the filename to be test
> (1/31/2005).txt. Thanks in advance ...
>
>
 
 
McKirahan





PostPosted: Fri Nov 04 15:49:17 CST 2005 Top

VB Scripts >> Filename with date modified appended to filename "Guido" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> need to find a way to change filenames that relect the filename and
> the date modified. I have found numerous ways to get the current date
> and time appended to the filename but nothing with date modified. I
> have users that need to have this in the filename and I am in search of
>
> some help in this matter. Example is a file named test.txt with a date
>
> modified 1/31/2005. I would like the filename to be test
> (1/31/2005).txt. Thanks in advance ...
>

You cannot have a "/" in a filename.

Will this help? Watch for word-wrap.

'*
'* Rename file with DateLastModified
'* "test.txt" => "test(11-04-2005).txt"
'*
Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "filesmod.vbs"
Const cFOL = "D:\Temp\"
'*
'* Declare Variables
'*
Dim strDAT
Dim intFIL
intFIL = 0
Dim strFIL
Dim intREN
Dim strREN
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objGF1
Dim objGF2
'*
'* Rename Files in Folder
'*
If Not objFSO.FolderExists(cFOL) Then WScript.Quit
Set objGF1 = objFSO.GetFolder(cFOL)
Set objGF2 = objGF1.Files
For Each strFIL in objGF2
If InStr(strFIL.Name,").") = 0 Then
strDAT = FormatDateTime(strFIL.DateLastModified,2)
strDAT = Replace(strDAT,"/","-")
strREN = strFIL.Name
intREN = InStrRev(strFIL.Name,".")
strREN = Left(strREN,intREN-1) & "(" & strDAT & ")" &
Mid(strREN,intREN)
objFSO.MoveFile cFOL & strFIL.Name, cFOL & strREN
intFIL = intFIL + 1
End If
Next
'*
'* Destroy Objects
'*
Set objGF2 = Nothing
Set objGF1 = Nothing
Set objFSO = Nothing
'*
'* Results
'*
MsgBox intFIL & " files were renamed in " & vbCrLf &
cFOL,vbInformation,cVBS


 
 
Dr





PostPosted: Sat Nov 05 15:16:43 CST 2005 Top

VB Scripts >> Filename with date modified appended to filename JRS: In article <EMail@HideDomain.com>
, dated Fri, 4 Nov 2005 06:57:58, seen in news:microsoft.public.scriptin
g.vbscript, Guido <EMail@HideDomain.com> posted :
> need to find a way to change filenames that relect the filename and
>the date modified. I have found numerous ways to get the current date
>and time appended to the filename but nothing with date modified. I
>have users that need to have this in the filename and I am in search of
>
>some help in this matter. Example is a file named test.txt with a date
>
>modified 1/31/2005. I would like the filename to be test
>(1/31/2005).txt. Thanks in advance ...

It is much better to use fixed-width strings for such purposes, and ones
with fields in a logical order. Eschew FFF; follow ISO 8601 and use
YYYY-MM-DD or YYYYMMDD. You don't *have* do disregard a FIPS.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
 
 
Guido





PostPosted: Mon Nov 07 18:45:44 CST 2005 Top

VB Scripts >> Filename with date modified appended to filename that works for me ... thanks