帮顶一个,使用字符分割来获取文件名的话,后缀名长度<>3会出错,可以使用%%~nF和%%~xF来获取文件名和后缀,就简单多了。
[Asm] 纯文本查看 复制代码 setlocal enabledelayedexpansion
set "filename=%~1"
for %%F in ("%filename%") do (
set "foldername=%%~nF"
set "extension=%%~xF"
)
[Asm] 纯文本查看 复制代码 @echo off
setlocal enabledelayedexpansion
set "filename=%~1"
for %%F in ("%filename%") do (
set "foldername=%%~nF"
set "extension=%%~xF"
)
if "%extension%"=="" (
mkdir "!foldername!" 2>nul
move "!foldername%!extension!" "!foldername!"
) else (
mkdir "!foldername!" 2>nul
move "!foldername!.*" "!foldername!"
)
echo 文件夹已创建并文件已移动。
|