@echo off
for /f "skip=1 delims=" %%i in ('dir /b /a-d /o-n /s "d:\分解\数据1\0001\lishi\*.txt"') do (
copy "%%i" "d:\分解\数据2\0001.txt"
goto :eof
)
@echo off
for /f "skip=1 delims=" %%i in ('dir /b /a-d /o-n /s "d:\分解\数据1\0002\lishi\*.txt"') do (
copy "%%i" "d:\分解\数据2\0002.txt"
goto :eof
)
......
@echo off
for /f "skip=1 delims=" %%i in ('dir /b /a-d /o-n /s "d:\分解\数据1\1330\lishi\*.txt"') do (
copy "%%i" "d:\分解\数据2\1330.txt"
goto :eof
)
上述代码是将一文件夹内倒数第二行的txt文本数据导出
现在欲将上述若干代码合而为一,自己试写了如下代码,但是只能导出0001.txt,错在哪?- @echo off&setlocal enabledelayedexpansion
- for /l %%x in (10001,1,11330) do (
- set y=%%x
- pushd "d:\分解\数据1\!y:~1!\lishi\"
- for /f "skip=1 delims=" %%i in ('dir /b /a-d /o-n /s *.txt') do (
- copy "%%i" "d:\分解\数据2\!y:~1!.txt"
- goto :eof
- )
- )
复制代码 |