输出到 .CSV?
Output to .CSV?
我有一个批处理文件,用于签入和签出一个项目,它工作正常但是否可以制作一个 VBS 将我的 .txt 文件转换为 .csv 以便更容易阅读或让批处理文件直接输出到.csv文件?
我的问题是我需要将 .txt/.log 转换为 .csv。
批处理文件
@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
输出:
9:27:14.94 Tue 10/20/2015
9:27:22.65 Tue 10/20/2015
9:28:37.00 Tue 10/20/2015
我需要电子表格如下所示:
Date | Time
DDMMYYYY | HHMMSS
格式化取决于区域的时间和日期,以便相应地调整并输出到文件。
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
@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%
%time%,%date% >>logs.CSV 会将其添加到 .csv 文件中,该文件将在 execel
中打开
我有一个批处理文件,用于签入和签出一个项目,它工作正常但是否可以制作一个 VBS 将我的 .txt 文件转换为 .csv 以便更容易阅读或让批处理文件直接输出到.csv文件?
我的问题是我需要将 .txt/.log 转换为 .csv。
批处理文件
@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
输出:
9:27:14.94 Tue 10/20/2015
9:27:22.65 Tue 10/20/2015
9:28:37.00 Tue 10/20/2015
我需要电子表格如下所示:
Date | Time
DDMMYYYY | HHMMSS
格式化取决于区域的时间和日期,以便相应地调整并输出到文件。
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
@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%
%time%,%date% >>logs.CSV 会将其添加到 .csv 文件中,该文件将在 execel
中打开