【发布时间】:2017-04-21 09:42:44
【问题描述】:
我的查询解决了包含一系列复杂子目录的大型图像目录,并且需要执行文件列表查找并移动所述文件。
我在 StackOverflow 和其他支持论坛上找到了一些可能的解决方案来解决我的请求,这是我目前的解决方案:
@echo off
set Source=C:\users\directory
set Target=C:\users\target
set FileList=C:\users\lookup\list.txt
echo.
if not exist "%Source%" echo Source folder "%Source%" not found & goto Exit
if not exist "%FileList%" echo File list "%FileList%" not found & goto Exit
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('type "%FileList%"') do move "%Source%\%%a" "%Target%"
:Exit
echo.
echo press the Space Bar to close this window.
pause > nul
这工作得很好,但只针对父目录。如何让这个批处理脚本从父目录自上而下搜索并找到查找列表中提供的所有匹配文件?
【问题讨论】:
-
for /F "delims=" %%a in ('type "%FileList%"') do for /F "delims=" %%b in ('dir /B /S /A:-D "%Source%\%%a"') do move "%%b" "%Target%"
标签: batch-file move