Computing.Net > Forums > Programming > batch file name date and time

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file name date and time

Reply to Message Icon

Name: hugsandy
Date: February 7, 2007 at 12:12:46 Pacific
OS: win xp / 2003
CPU/Ram: interl
Product: hp
Comment:

hi
how can i create a text file using batch file with date and time in name
eg testThu 02/08/2007 2300.txt

and also i want to read a text file which has list of IP address and execute same command one by one with all the ip address in the file
the command is a snmp query

getmany -v1 < ipaddr.txt public 1.3.6.1.4.1.x.x.x.x.x.x>>test.txt


Thanks
sandy



Sponsored Link
Ads by Google

Response Number 1
Name: templarg
Date: February 7, 2007 at 13:40:43 Pacific
Reply:

It's not possible to have the / character in a filename


0

Response Number 2
Name: Mechanix2Go
Date: February 7, 2007 at 13:57:28 Pacific
Reply:

The dated file:

::==sandy.bat
@echo off
setLocal EnableDelayedExpansion

:: get sys YMD into vars

@echo off

:: YYYY getter
> syyyy.d echo a 100
>> syyyy.d echo mov ah,2a
>> syyyy.d echo int 21
>> syyyy.d echo.
>> syyyy.d echo p=100 2
>> syyyy.d echo n sizeYYYY
>> syyyy.d echo w
>> syyyy.d echo q
debug < syyyy.d > nul
:: OK

:: MM getter
> sMM.d echo a 100
>> sMM.d echo mov ah,2a
>> sMM.d echo int 21
>> sMM.d echo mov cx,0
>> sMM.d echo mov cl,dh
>> sMM.d echo.
>> sMM.d echo p=100 4
>> sMM.d echo n sizeMM
>> sMM.d echo w
>> sMM.d echo q
debug < sMM.d > nul
:: OK

:: DD getter
> sDD.d echo a 100
>> sDD.d echo mov ah,2a
>> sDD.d echo int 21
>> sDD.d echo mov cx,0
>> sDD.d echo mov cl,dl
>> sDD.d echo.
>> sDD.d echo p=100 4
>> sDD.d echo n sizeDD
>> sDD.d echo w
>> sDD.d echo q
debug < sDD.d > nul
:: OK
del *.d

for %%F in (sizeYYYY sizeMM sizeDD) do call :sub1 %%F
set /p YYYY=<sizeYYYY.#
set /p MM=<sizeMM.#
if %MM% LSS 10 set MM=0%MM%
set /p DD=<sizeDD.#
if %DD% LSS 10 set DD=0%DD%
del size*.*
set YMD=%YYYY%%MM%%DD%
echo YMD=%YMD%
@echo off > test%YMD%.txt
goto :eof

:sub1
> %1.# echo %~z1
goto :eof
:: ======================== DONE

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

To process multiple IPs:

::== sandy2.bat
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%A in (iplist) do (
echo my.exe %%A
)
:: ===== DONE



=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file name date and time

file naming as date and time www.computing.net/answers/programming/file-naming-as-date-and-time/17986.html

Batch File - date and time on files www.computing.net/answers/programming/batch-file-date-and-time-on-files/9137.html

list file's current date and time. www.computing.net/answers/programming/list-files-current-date-and-time/11922.html