本帖最后由 wqte45 于 2024-2-21 15:51 编辑
回复 wqte45
亦可如此》for %%v in ("str1" "str2" "str3") do echo,%%~v
aloha20200628 发表于 2024-2-21 12:57
本来代码都写了好几个了,其实每一个都能用,但是看完你们的回复,我又又想改了,改了好几个版本了,越改越长 :lol :lol
上一次这样写的- @echo off
- setlocal
- for /f "skip=3 delims=" %%i in ('crc32 "%~1"') do set str=%%i
- if "%str:~-8%"=="cified." (echo File does not exist & goto exit)
- for %%z in ("file : %~1") do echo %%~z
- echo crc32 : %str:~-8%
- for %%z in ("rename: %~n1 %str:~-8%%~x1") do echo %%~z
- ren "%~1" "%~n1 %str:~-8%%~x1"
- :exit
- endlocal & timeout /t 3 & exit/b
复制代码 现在又改了:lol- @echo off
- for /f "skip=3 delims=" %%i in ('crc32 "%~1"') do set str=%%i
- if "%str:~-8%"=="cified." (echo File does not exist & goto exit)
- for %%z in ("file : %~1" "crc32 : %str:~-8%" "rename: %~n1 %str:~-8%%~x1") do echo %%~z
- ren "%~1" "%~n1 %str:~-8%%~x1"
- :exit
- timeout /t 3 & exit/b
复制代码 输出结果:- D:\Hash & Rename\2>"Hash&Ren3.bat" "C:\Users\MEN\Desktop\1&6,1&&6.txt"
- 100% complete
-
- file : C:\Users\MEN\Desktop\1&6,1&&6.txt
- crc32 : 18526A77
- rename: 1&6,1&&6 18526A77.txt
-
- 等待 0 秒,按一个键继续 ...
复制代码 话说setlocal 和endlocal重要吗?
另外set/p="%~1"<nul好像就没办法 像你这样 里面放三个字符串了吧? |