根据文件名创建文件夹,并使用转义字符移动文件! ^

时间:2019-03-20 18:27:06

标签: windows command character filenames

此命令有效,但是如果文件名具有转义字符(如 ^ ),则会导致“系统找不到指定的文件”。那么我怎样才能使其也适用于转义字符?

谢谢

@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

0 个答案:

没有答案