|
|
本帖最后由 macheal 于 2021-3-19 08:38 编辑
问题:
我想从一个文件夹中,拷贝出来我需要的文件名(需要关键字搜索)到另外一个文件夹。以下是我参考其他大神的代码,但会出现以下错误。谢谢大神帮忙
错误提示
The system cannot find the path specified.
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
0 file(s) copied.
Press any key to continue . . .
代码- @echo off
- set "FileTxt=C:\Copytest\list.txt"
- set "SourDir=C:\Copytest\Copytest\File"
- set "DestDir=C:\Copytest\CopyFile"
- cd /d "%SourDir%"
- for /f %%a in ('type "%FileTxt%"') do (
- for /f %%i in ('dir /a-d /b /s^|findstr "%%a"') do (
- set "DirName=%%~dpi"
- setlocal enabledelayedexpansion
- set "DirName=!DirName:%SourDir%=!"
- if not exist "%DestDir%!DirName!" md "%DestDir%!DirName!"
- copy "%%i" "%DestDir%!DirName!"
- endlocal
-
- ))
- pause
复制代码 |
|