回复 1# adfs945
之前已经有过类似的了,要善于搜索- @echo off
- set /p yourprogramname=what your program name:
- :start
- cd /d "%~dp0"
- if not exist %yourprogramname%.txt (
- set /a "fx=0"
- )
- if exist "%yourprogramname%.txt" (
- set /a "fx=0"
- set /a "b=1"
- set /a "fx=%fx%+1"
- set "OutFile=%yourprogramname%%fx%.txt"
- )
- if "%fx%" equ "0" (
- set "OutFile=%yourprogramname%.txt"
- )
- :1
- (for /f "delims=" %%i in ('dir /b /a-d *.*') do (
- if "%%i" neq "%OutFile%" (
- echo,%%~ni
- )
- ))>"%OutFile%"
- if exist "%yourprogramname%0 .txt" (
- ren "%yourprogramname%0.txt" "%yourprogramname%1 .txt"
- )
- pause >nul
- goto start
复制代码 这个脚本会给出一个类似"文件名0.txt"的,如果不用的话就在进下一个循环的时候改掉"文件名1.txt" |