Zxian Posted March 20, 2006 Posted March 20, 2006 I'm trying to find a way of running 7-zip to archive my "My Documents" folder and store it in a file that contains the date (and possibly time) in the filename for quick reference of when the last backup was made.The "date /T" command in XP provides the date, but the string contains slashes, which XP doesn't like for filenames (for obvious reasons). Any leads as to how to do this would be appreciated. Even just an example of how to make a .txt file with the date as part of the filename.Thanks in advance.
BeenThereB4 Posted March 20, 2006 Posted March 20, 2006 Any leads as to how to do this would be appreciated. Even just an example of how to make a .txt file with the date as part of the filename.Thanks in advance. NAMEDATE Version 5.03Copyright © 1999, 2002-2005 by James Greene. All rights reserved.http://www.informatics-consulting.chNAMEDATE adds a date to a given file's name.Usage: NAMEDATE.EXE [switches] filenames(s)where [switches] may be (**) /F = put the date before the original filename (**) /X = put the date as an extension to the original filename (*) /8 = Use DOS 8.3 filenames (xxYYMMDD.ext) /Z:"[format]" = date format (see documentation) /ZZ:"[format]" = enhanced format (see documentation) (new in v5.0) /M = use the file's modification date/time /O+[d] = add [d] days to the date /O-[d] = subtract [d] days from the date /A+[m] = add [m] minutes to the time /A-[m] = subtract [m] minutes from the time
Zxian Posted March 21, 2006 Author Posted March 21, 2006 oOoo... this looks helpful. Thanks BeenThereB4.
gunsmokingman Posted March 21, 2006 Posted March 21, 2006 How about a VBS file for the dateDim D1 : D1 = replace(Date,"/","_") MsgBox D1 & "_" & "Your_File_Name", 0 + 32,"Date"
Delprat Posted March 21, 2006 Posted March 21, 2006 The "date /T" command in XP provides the date, but the string contains slashes, which XP doesn't like for filenames (for obvious reasons).here is a solution to name a file using YYYYMMDD format, providing that system date format is MM/DD/YYYY@echo offsetlocal enableextensionsset arcname=MyDocs_%date:~-4%%date:~0,2%%date:~3,2%.7zecho Making archive : %arcname%...rem call 7za here
IcemanND Posted March 21, 2006 Posted March 21, 2006 try this in cmd script: %date:/=-%will output the date with - instead of /
gunsmokingman Posted March 21, 2006 Posted March 21, 2006 (edited) Here is some more VBS for the time, sorry I made a mistake in my first post thought you wanted dated.MsgBox Hour(Now) & "_" & Minute(Now) & "_" & Second(Now) Dim T1 : T1 = Replace(Time,":","_") : MsgBox T1 Edited March 21, 2006 by gunsmokingman
Zxian Posted March 30, 2006 Author Posted March 30, 2006 Wow... this is a lot better than I had originally hoped. Thank you all very much for the help.I really should start learning VBS. gunsmokingman - where did you pick up VBS? Any good online tutorials? I know that someone posted a few links to some here a while back, but that post was probably close to a year ago.
SilverBulletUK Posted March 30, 2006 Posted March 30, 2006 (edited) Try this, it sets the variables in the batch file for use later on within it...@Echo off::Setting Path VariablesSet BACKUPDIR=C:Set TARGET=%USERPROFILE%\MYDOCU~1Set ZIPEXE=C:::Grabbing date variables...@For /F "tokens=1 delims=/ " %%A in ('Date /t') do set DD=%%A@For /F "tokens=2 delims=/ " %%B in ('Date /t') do set MM=%%B@For /F "tokens=3 delims=/ " %%C in ('Date /t') do set YY=%%CSet CUSTOMDATE=%DD%-%MM%-%YY%:: Running7Z...start /wait %ZIPEXE%\7za.exe a -tzip %BACKUPDIR%\MyDoc%CUSTOMDATE%.zip "%TARGET%\*"ExitHope this helps you. SilverB. Edited March 30, 2006 by SilverBulletUK
gunsmokingman Posted April 4, 2006 Posted April 4, 2006 Wow... this is a lot better than I had originally hoped. Thank you all very much for the help.I really should start learning VBS. gunsmokingman - where did you pick up VBS? Any good online tutorials? I know that someone posted a few links to some here a while back, but that post was probably close to a year ago.I go here to learn about VBS scripting The Hey, Scripting Guy! Archive they have a lot of templates and links to more information.
Zxian Posted April 6, 2006 Author Posted April 6, 2006 I go here to learn about VBS scripting The Hey, Scripting Guy! Archive they have a lot of templates and links to more information.Thanks for the link. I'll definately check that out.
gunsmokingman Posted April 6, 2006 Posted April 6, 2006 I go here to learn about VBS scripting The Hey, Scripting Guy! Archive they have a lot of templates and links to more information.Thanks for the link. I'll definately check that out. There articles are well written and are easy to understand, heck if I can learn how to script any body can.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now