0

I have a batch file that checks in an item and checks it out, It works fine but Is it possible to make a VBS that would turn my .txt file to a .csv so it is easier to read or to make the batch file directly output it to a .csv file?

My issue is I need to convert the .txt/.log to a .csv.

The Batch file

@echo off
title Checkin
color 0a

SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  set "DEL=%%a"
)


cls
:home
cls
call :ColorText 0b "---------------------------------------"
echo.
call :ColorText 74 "-               Welcome               -"
echo.
call :ColorText 0b "---------------------------------------"
echo.
call :ColorText 0a "        Ready, Awaiting Scan...        "
echo.
set /p scan=
cls
call :ColorText 0a "-            Please Wait...           -"
echo.
echo %time% %date% >>%scan%.log
echo %scan% %date% %time% >>master.xml
ping localhost -n 3 >nul
echo.
call :ColorText 0a "-               Success!              -"
echo.
ping localhost -n 2 >nul
goto :home


:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1

The Output:

 9:27:14.94 Tue 10/20/2015 
 9:27:22.65 Tue 10/20/2015 
 9:28:37.00 Tue 10/20/2015 

I need the Spreadsheet to look like:

    Date  |  Time
 DDMMYYYY | HHMMSS
Display Word
  • 96
  • 1
  • 3
  • 10

3 Answers3

1
@echo off

for /f "delims=." %%a in ('wmic os get LocalDateTime^| findstr [0-9]') do set "$all=%%a"

>>scan.csv echo %$all:~0,8%;%$all:~8%
SachaDee
  • 8,843
  • 2
  • 18
  • 29
0

Formats the time & date which is regional dependent so adjust accordingly and outputs to a file.

FOR /F "tokens=1-3 delims=:" %%G IN ("%TIME: =0%") DO set oTime=%%G%%H%%I

FOR /F "tokens=2-4 delims= /" %%G IN ("%DATE%") DO set oDate=%%G%%H%%I

echo %oDate%,%oTime% >>scan.csv
Squashman
  • 11,987
  • 5
  • 23
  • 33
-1

%time%,%date% >>logs.CSV will add it to a .csv file which will open in execel

Display Word
  • 96
  • 1
  • 3
  • 10