此论坛中有人帮我开发了一个批处理文件,根据当前月份将文件从一个文件夹移动到另一个文件夹,如下所示:
::echo You were in %cd% ran from batch file "%~f0"
pushd "%~dp0"
::echo You are in now in %cd%
::popd
::@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
::Set "Dir1=C:\Directory1"
::Set "Dir2=C:\Directory2"
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
set "Dir1=%cd%"
::echo %Dir1%
set "Dir2=%cd%"
::echo %Dir2%
:: Build Mon[01..12] array
Set Cnt=100
For %%A in (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
) Do Set /A Cnt+=1&Set Mon[!Cnt:~-2!]=%%A
::Set Mon[
For /f "delims=" %%A in (
' Dir /B/A-D "%Dir1%\?-??-???? - * - *.pdf" ^|findstr "[01][0-9][0-3]
[0-9] 20 [0-9][0-9]\.pdf$" '
) Do (
Set "File=%%~nA"
Call Set "MoveTo=%Dir2%\!File:~-4!\%%Mon[!File:~-8,2!]%%\"
MD "!MoveTo!" >Nul 2>&1
Move "%%~fA" "!MoveTo!"
)
popd
此脚本运行良好,但它不处理具有"
符号的命名的文件,例如:'10"'
。
有人可以帮我修改此脚本以允许处理此符号。
提前致谢!
答案 0 :(得分:0)
文件名中允许使用扩展字符U+201C
和U+201D
。确保您的脚本是UTF8并尝试使用这些字符。
" U+0022 Double quotation mark <= not this one
“ U+201C Left double quotation mark
” U+201D Right double quotation mark