此命令有效,但是如果文件名具有转义字符(如!或 ^ ),则会导致“系统找不到指定的文件”。那么我怎样才能使其也适用于转义字符?
谢谢
@echo off
setlocal enabledelayedexpansion
for %%A in (*.*) do (
echo file found %%A
for /f "delims=+" %%B in ("%%A") do set fname=%%~nB
for /f "delims=+" %%C in ("%%A") do set fextn=%%~xC
for /f "tokens=1* delims=+" %%D in ("!fname!") do set folname=%%D
echo folder name !folname!
if not exist "!folname!" (
echo Folder !folname! does not exist, creating
md "!folname!"
) else (
echo Folder !folname! exists
)
echo Moving file %%A to folder !folname!
move "%%A" "!folname!"
)
echo Finished
pause