本帖最后由 qixiaobin0715 于 2021-6-2 11:53 编辑
回复 7# haichuan5121
主要原因是第二列空白造成的,小批量运行下列代码试试,未经测试:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d *.csv') do (
- set n=0
- for /f "delims=" %%j in (%%i) do (
- set "var=%%j"
- set "var=!var:,,=,@,!"
- for /f "tokens=3 delims=," %%a in ("!var!") do (
- set /a n+=1
- if !n!==2 (
- set str=%%a
- ) else if !n!==4 (
- set str=!str! %%a
- set "str=!str:/=!"
- )
- )
- )
- if not exist "!str!.csv" (
- ren "%%i" "!str!.csv"
- ) else (
- set k=1
- for /l %%x in (1,1,9) do (
- if !k!==1 if not exist "!str!%%x.csv" ren "%%i" "!str!%%x.csv"&set k=0
- )
- )
- )
- pause
复制代码
|