1

i am new to batch file programming. the hierarchy for the folder is like c:\Test\ contains multiple folders say suppose from 1 to 5 and each folder contains sub folders. say suppose there is folder name ABC in every 1 to 5 folders and in that *.txt files what i am looking is to search for ABC folder if i gave the path C:\Test it will look for ABC folder and copy the *.txt file in c:\copytest folder. is it possible ? i wanted to do this using batch file programming. Thanks! in advanced.

4

1 回答 1

2

打败我。

@echo off

setlocal

set ROOT_DIR=c:\temp\source
set DIR_TO_MATCH=ABC
set TARGET_DIR=c:\temp\target

for /f "tokens=*" %%F in ('dir "%ROOT_DIR%\*.txt" /s /b /a-d ^| %SystemRoot%\System32\find.exe "\%DIR_TO_MATCH%\"') do (
    move "%%F" "%TARGET_DIR%"
    )

endlocal
于 2012-07-27T22:06:51.967 回答