本帖最后由 terse 于 2024-4-13 08:00 编辑
修正获取文件方式和文件序列问题,这里还是DIR好一点- @echo off&setlocal enabledelayedexpansion
- set /p num=选择输入1,2,3:
- cls
- if !num! equ 1 (
- set #1=张三
- set #2=李四
- set #3=王五
- goto :next
- ) else (
- if !num! equ 2 (
- set #1=六六
- set #2=七七
- set #3=八八
- goto :next
- ) else (
- if !num! equ 3 (
- set #1=丹丹
- set #2=滴滴
- set #3=美美
- goto :next
- )
- )
- )
- echo 没按指定选择输入(1,2,3)
- pause
- exit
- :next
- for /f "tokens=*" %%F in ('dir /b /a-d') do (
- if "%%~nxF" neq "%~nx0" if not defined _%%~nF (
- set /a "n+=1
- set "_%%~nF=!n!"
- set file_!n!="%%~xnF"
- ) else (
- for %%i in ("!_%%~nF!") do set file_%%~i=!file_%%~i! "%%~xnF"
- )
- )
复制代码 拖入文件- @echo off&setlocal enabledelayedexpansion
- if "%~1" == "" exit
- set /p num=选择输入1,2,3:
- cls
- if !num! equ 1 (
- set #1=张三
- set #2=李四
- set #3=王五
- goto :next
- ) else (
- if !num! equ 2 (
- set #1=六六
- set #2=七七
- set #3=八八
- goto :next
- ) else (
- if !num! equ 3 (
- set #1=丹丹
- set #2=滴滴
- set #3=美美
- goto :next
- )
- )
- )
- echo 没按指定选择输入(1,2,3)
- pause
- exit
- :next
- for %%F in (%*) do (
- if "%%~nxF" neq "%~nx0" if not defined _%%~nF (
- set /a "n+=1
- set "_%%~nF=!n!"
- set file_!n!="%%~xnF"
- ) else (
- for %%i in ("!_%%~nF!") do set file_%%~i=!file_%%~i! "%%~xnF"
- )
- )
- for /l %%i in (1,1,!n!) do for %%a in (!file_%%i!) do echo ren "%%~nxa" "!#%%i!-%%~nxa" !#%%i!
- pause
复制代码
|