Solved Batch file to find logfile.txt on c:\ drive

February 12, 2013 at 12:18:51
Specs: Windows 7
need to write a batch file to find logfile.txt on the C:\ drive. If file is not found need to creat the file with date and time in the file. if it does exist, exit the batch

See More: Batch file to find logfile.txt on c:\ drive

Report •

✔ Best Answer
February 12, 2013 at 21:14:32
try this, then:
@echo off & setlocal
dir /b /s c:\logfile.txt|| > logfile.txt echo %date% %time% & echo %date% %time%
pause
::==== end
you should get either the file's path, or a time and date.


#1
February 12, 2013 at 17:00:46
@dir /b /s c:\logfile.txt|| > logfile.txt echo %date% %time%

Report •

#2
February 12, 2013 at 18:35:07
didn't work, copied and pasted to note pad, saved as .bat

Report •

#3
February 12, 2013 at 21:09:28
Works for me.

Hi, nbrane

=====================
M2 Golden-Triangle


Report •

Related Solutions

#4
February 12, 2013 at 21:14:32
✔ Best Answer
try this, then:
@echo off & setlocal
dir /b /s c:\logfile.txt|| > logfile.txt echo %date% %time% & echo %date% %time%
pause
::==== end
you should get either the file's path, or a time and date.

Report •

#5
February 12, 2013 at 23:55:34
Lemme guess: OP didn't look to see if file was created.

I always get queasy when somebody says it opened a cmd window.

LOL

=====================
M2 Golden-Triangle


Report •

#6
February 13, 2013 at 03:37:49
thanks nbrane, that one seemed to work best for me. The whole concept of programming just gives me migraines I swear.

Report •

#7
February 13, 2013 at 10:18:51
@M2: hello, yeh, I kind of figured it was something like that.
@op: I hardly ever work in gui, so I tend to forget about/ignore issues having to do
with disappearing or non-informative command-windows. As for the migraines, maybe it's the language you're using. My theory is people have a "favorite" language, but also that each language has its strengths and weaknesses. C gives me fits, and I remember Cobol courses in school that made me want to jump out a window. I wrote a program (in basic) to write the bulk of my cobol program to avoid all that redundant "self-documenting" "identification division" stuff.

Report •

Ask Question