Saved Bookmarks
| 1. |
Solve : Date and timestamp in filename? |
|
Answer» Hi, Hi, You could use a simple script, but, in my script, you have to GIVE the date and time yourself Code: [Select]@echo off echo. echo. set /P choice= What's the date : set /P choiec2= What's the time : >> (location)/%choice%%choice2%.txt but, i dont think that this is something that you are LOOKING for Thanks, but no. I want it to determine the system date and time within the script (if there's no DOS command with a switch) and use that info to apply it to the filename.Code: [Select]@echo off for /f "tokens=2-4 delims=/ " %%i in ("%date%") do ( set mm=%%i set dd=%%j set yy=%%k ) set today=%yy%%mm%%dd% for /f "tokens=1-4 delims=:. " %%i in ("%time%") do ( set hh=%%i set mm=%%j set ss=%%k ) set now=%hh%%mm%%ss% Once you generate the %today% and %now% tokens, you can use them as you wish: Test.txt >> Test%today%%now%.txt 8-) PS. You failed to mention your OS, so this code may or may not work on your machineThanks - this worked just great! I puts a space between the date and timestamp and I'm not sure why, but it doesn't matter. Thanks again ! Quote [code] Curious ... what OS does that work in? XP's command prompt? Also, wanted to mention a program that I remember using, some years ago. Used it with some sort of scheduler, to set environment variables, so that I could use pkzip to archive some stuff weekly - filenames based on the date of creation of the zip file. Kept them all in one directory. www.ferg.org/fdate/ Fdate "Fdate is a utility for doing date formatting and date arithmetic in MS-DOS batch files. It runs under MS-DOS and WINDOWS. Fdate's output can be placed into an environment variable that can be used in a batch file in whatever way is useful to you. Fdate is freeware ("zero-cost shareware")." Worked great for me. I didn't find it mentioned anywhere with a search - I was surprised. This is a Windows 2003 Server. I'll go look for that s/w - SOUNDS good - especially the price! |
|