从文本文件列表 (windows) 将文件从一个目录移动到另一个目录的批处理脚本

Batch script for move files from one directory to another from list of text files (windows)

我有两个文件夹 12。我将文件列表名称保存在文本 C:\a\filelist.txt 中。文件列表包含文件夹 1

中可用的文件

我想使用文本中的文件列表将文件从文件夹 1 移动到 2

@echo off
move C:\a\"new.txt" C:\a
pause

这是一个 option, which uses the built-in 可执行文件,用于检查文本文件中列出的文件:

@For /F "EOL=| Delims=" %%# In (
    'Dir /B /A:-D "C:\a" ^| "%__AppDir__%findStr.exe" /E /L /I /G:"C:\a\filelist.txt"'
) Do @Move /Y "C:\a\%%#" "C:\a"

这是一个简短的单行命令提示符,(),版本:

For /F "EOL=|Delims=" %# In ('Dir /B/A-D "C:\a"^|FindStr /ELIG:"C:\a\filelist.txt"')Do @Move /Y "C:\a\%#" "C:\a"

这假定您的 %PATH%%PATHEXT% 变量仍然保持其适当的默认值,或者 findstr.exe 位于当前目录中。