|
Answer» Here is the batch file...
@echo off dir %1 | find "bytes free" > c:\freespace.txt echo On|set /p =%date% >> c:\time.txt echo at| time /t >> c:\time.txt Echo The %1 DRIVE on %COMPUTERNAME% computer has: >> c:\time.txt type c:\time.txt type c:\freespace.txt pause
int the Time.txt file the output comes like so... Tue 10/11/2011 08:29 PM The %1 drive on %COMPUTERNAME% computer has:
What I can't seem to do is get it all on ONE line... What am I doing wrong?It seems the problem you are having is more with the fact that you are trying to code the way you think, and not the way batch thinks. The tricky part with this code is the time /t command. Because I don't know of any better way to do it, I'm going to use my trusty FOR command to help with this.
Code: [Select]@echo off dir %1 | find "bytes free" > c:\freespace.txt for /F "delims=" %%A in ('time /t') do (set curtime=%%A) echo On %date% at %curtime% The %1 drive on %COMPUTERNAME% computer has: >> c:\time.txt type c:\time.txt type c:\freespace.txt pause
If you are wanting a full output on one line in a certain file, try this:
Code: [Select]@echo off dir %1 | find "bytes free" > c:\freespace.txt set /p bytes=<c:\freespace.txt for /f "delims=" %%A in ('time /t') do (set curtime=%%A) echo On %date% at %curtime% The %1 drive on %COMPUTERNAME% computer has: %bytes%>> c:\time.txt type c:\time.txt pause hmmm...I never thought of using a for STATEMENT in a batch file, heh. I will give that a try. Thanks!Code: [Select]for /f "tokens=1,2* delims= " %%A in ('dir t:\ ^| find "bytes free"') do set bytesfree=%%C echo On %date% at %time% drive %1 has %bytesfree%
|