bat-CSV文件转MD文件
1. bat文件里面写死文件名
@echo off & setlocal enabledelayedexpansion
SET filepath=MD-CSV.csv
SET mdfile=MD-CSV.md
:: 当前目录下创建文件
cd. >%mdfile%
set /a index=0
for /f "delims=" %%a in (%filepath%) do (
set /a index+=1
set data1=%%a
set "data1=!data1:,= | !"
set "data1=| !data1! |"
echo !data1!>>%mdfile%
if !index! == 1 (
set /a sumstr=0
set "twostr=|"
for %%i in (!data1!)do (
if "%%i"=="|" (
set/a sumstr+=1
if !sumstr! == 1 (
set "twostr=!twostr!"
) else (
set "twostr=!twostr! --- |"
)
)
)
echo !twostr!>>%mdfile%
)
)
pause
2. 拖入文件
生成的md文件格式为CSV2MD-CSV文件名.md
@echo off & setlocal enabledelayedexpansion
set nativecsvfile=%~1
set csvfile=%~n1
set "mdfile=CSV2MD-!csvfile!.md"
:: 当前目录下创建文件
cd. >%mdfile%
set /a index=0
for /f "delims=" %%a in (%nativecsvfile%) do (
set /a index+=1
set data1=%%a
set "data1=!data1:,= | !"
set "data1=| !data1! |"
echo !data1!>>%mdfile%
if !index! == 1 (
set /a sumstr=0
set "twostr=|"
for %%i in (!data1!)do (
if "%%i"=="|" (
set/a sumstr+=1
if !sumstr! == 1 (
set "twostr=!twostr!"
) else (
set "twostr=!twostr! --- |"
)
)
)
echo !twostr!>>%mdfile%
)
)
pause