![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How do I replace all characters in the "Now" date? I'm trying to rename a file using all of the characters (including the time) from the "Now" command, but I'm stuck. This is very close (but it doesn't include the time, only the date): Set objFSO = CreateObject("Scripting.FileSystemObject") N=Now strFNA = Right(Year(N),4) & "." & Right(100+Month(N),2) & "." & Right(100+Day(N),2) objFSO.MoveFile "testfile.txt", strFNA & ".txt" All I want the filename to be is numeric digits and the extension. Suggestions? Thanks, Ed |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How do I replace all characters in the "Now" date? Ed wrote on 28 okt 2008 in microsoft.public.scripting.vbscript: Quote: > I'm trying to rename a file using all of the characters (including the > time) from the "Now" command, but I'm stuck. > > This is very close (but it doesn't include the time, only the date): > > Set objFSO = CreateObject("Scripting.FileSystemObject") > N=Now > strFNA = Right(Year(N),4) & "." & Right(100+Month(N),2) & "." & > Right(100+Day(N),2) > objFSO.MoveFile "testfile.txt", strFNA & ".txt" > > All I want the filename to be is numeric digits and the extension. T(hour(N),2) & T(minute(N),2) & ".txt" function T(s,n) T = right("000"&s,n) end function not tested -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How do I replace all characters in the "Now" date? "Ed" <edflecko@xxxxxx> wrote in message news:e2b6efe7-ebd9-4918-8d37-59ea07b3980d@xxxxxx Quote: > I'm trying to rename a file using all of the characters (including the > time) from the "Now" command, but I'm stuck. > > This is very close (but it doesn't include the time, only the date): > > Set objFSO = CreateObject("Scripting.FileSystemObject") > N=Now > strFNA = Right(Year(N),4) & "." & Right(100+Month(N),2) & "." & > Right(100+Day(N),2) > objFSO.MoveFile "testfile.txt", strFNA & ".txt" > > All I want the filename to be is numeric digits and the extension. > > Suggestions? > > Thanks, > Ed Set oRegEx = CreateObject("VBScript.RegExp") oRegEx.Global = True oRegEx.Pattern = "[^0-9]" WScript.echo oRegEx.Replace(Now(), "") |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How do I replace all characters in the "Now" date? In microsoft.public.scripting.vbscript message <Xns9B45B6D3047C2eejj99@xxxxxx 94.109.133.242>, Tue, 28 Oct 2008 16:58:26, Evertjan. <exjxw.hannivoort@ interxnl.net> posted: Quote: >Ed wrote on 28 okt 2008 in microsoft.public.scripting.vbscript: > Quote: >> I'm trying to rename a file using all of the characters (including the >> time) from the "Now" command, but I'm stuck. >> >> This is very close (but it doesn't include the time, only the date): >> >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> N=Now >> strFNA = Right(Year(N),4) & "." & Right(100+Month(N),2) & "." & >> Right(100+Day(N),2) >> objFSO.MoveFile "testfile.txt", strFNA & ".txt" >> >> All I want the filename to be is numeric digits and the extension. >strDateFile = year(N) & T(month(N),2) & T(day(N),2) &_ > T(hour(N),2) & T(minute(N),2) & ".txt" > >function T(s,n) > T = right("000"&s,n) >end function > >not tested N = Now strDateFile = (year(N)*1e10 + month(N)*1e8 + day(N)*1e6 + _ hour(N)*1e4 + minute(N)*1e2 + second(N)) & ".txt" document.write strDateFile ' Tested -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. 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 vb-dates.htm pas-time.htm critdate.htm etc. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Fetch special characters like "Ñ" and absolute URL from href attribute of anchors | VB Script | |||
| How to prevent that the lower part of the characters <g, j, p, q, y> are "cut off" at the four top lines <From:, Date:, To:, Subject:>?? | Vista mail | |||
| Blank "Date Taken / Date Modified" field in Vista | Vista file management | |||
| How to insert the "modified time" attribute in "date taken" attribute in batch mode-in vista or theough a software? | Vista file management | |||
| How to insert the "modified time" attribute in "date taken" attrib | Vista music pictures video | |||