我当前正在尝试重命名最近创建的文件夹,我知道有一个名为REN(或)RENAME的命令,但是它用于重命名文件而不是文件夹。
Below is the code that i am working to achieve this.
for %%# in ("%mask%_*") do (
if not exist "%destination_dir%\%mask%" mkdir "%destination_dir%\%mask%"
move /y "%%~#" "%destination_dir%\%mask%"
if exist "%destination_dir%\%mask%" ren "%destination_dir%\%mask%_%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%"
)
如何实现这一目标?
在以if exist
命令ren开头的批处理代码中,ren仅从1个参数开始。因此,缺少用于文件夹/文件的新名称的第二个参数。请注意,第二个参数必须始终只是不带路径的文件/文件夹的新名称。
您的批处理代码最有可能是:
for %%# in ("%mask%_*") do (
if not exist "%destination_dir%\%mask%" mkdir "%destination_dir%\%mask%"
move /y "%%~#" "%destination_dir%\%mask%"
if exist "%destination_dir%\%mask%" ren "%destination_dir%\%mask%" "%mask%_%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%"
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句