Você pode percorrer uma vez a lista de "palavras-chave" e usar os valores de palavra-chave iterados junto com alguns caracteres curinga incluídos como sequências de pesquisa , por exemplo, *<Keyword>*
. Você pode percorrer a árvore de diretórios de cada valor de caminho UNC de sua lista de arquivos e executar a operação de cópia somente para aqueles que existirem correspondentes à string de pesquisa "keywords".
Essentially though...
- The first for /f loop will read each line of the string file list one by one and each line's value will be an iterated value that is passed at the first argument to the call command.
- The second for /f loop will read each line of the UNC path file list one by one and pass it and the first argument value passed by the first for /f loop as two arguments with its call command.
- The last for /r loop will recursively search the iterated UNC path with the iterated string value as separate arguments it was passed, and then copy over all matching files.
Script em lote
@ECHO ON
SET "strList=\server\Folder\Path\SearchStrings.txt"
SET "pathList=\server\Folder\Path\UNCPaths.txt"
SET "targetPath=\server\target\folder\path"
FOR /F "USEBACKQ TOKENS=*" %%S IN ("%strList%") DO CALL :Paths "%%~S"
PAUSE
EXIT
:Paths
FOR /F "USEBACKQ TOKENS=*" %%P IN ("%pathList%") DO CALL :FileExist "%~1" "%%~P"
GOTO :EOF
:FileExist
FOR /R "%~2" %%C IN (*%~1*) DO XCOPY /F /Y "%%~C" "%targetPath%\"
GOTO :EOF
Mais recursos
-
The CALL command will pass control to the statement after the label specified along with any specified parameters. To exit the subroutine specify
GOTO:eof
this will transfer control to the end of the current subroutine. -
FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters] Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree. If no directory specification is specified after /R then the current directory is assumed. If set is just a single period (.) character then it will just enumerate the directory tree.