- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d *.*^|find /i /v "%~nx0"') do (
- set str2=!str1!
- set str1=!var!
- set var=%%~ni
- if defined str2 (
- if not defined var1 (
- set "var1=!str2!"
- >"!str2!.txt" echo ^^^<var^^^>!str2!^^^</var^^^> ^^^<var^^^>!str1!^^^</var^^^> ^^^<var^^^>%%~ni^^^</var^^^>
- ) else (
- >"!str2!.txt" echo ^^^<var^^^>!var1!^^^</var^^^> ^^^<var^^^>!str2!^^^</var^^^> ^^^<var^^^>!str1!^^^</var^^^>
- set "var1=!str2!"
- set "var2=!var1!"
- )))
- >"!str1!.txt" echo ^^^<var^^^>!str2!^^^</var^^^> ^^^<var^^^>!str1!^^^</var^^^> ^^^<var^^^>!var!^^^</var^^^>
- >"!var!.txt" echo ^^^<var^^^>!str2!^^^</var^^^> ^^^<var^^^>!str1!^^^</var^^^> ^^^<var^^^>!var!^^^</var^^^>
- pause
复制代码 dir的问题- for /f "delims=" %%i in ('dir /b /a-d') do (
- set/a n+=1
- echo %%i
- if !n! gtr 5 goto :eof
- )
复制代码 排序- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in ('dir /b /a-d') do (
- set str=//////////%%i
- set .!str:~-10! !random!=%%i
- )
- for /f "tokens=2 delims==" %%i in ('set .') do echo %%i
- pause
复制代码
|