English 中文(简体)
• 如何制作一个Batch文档,在子夹中复制红ps,然后复制件。
原标题:How to create a Batch file to copy zips in subfolders to another folder

我有一盒子,称为<代码>Private,其中有多个子。 其中每个文件夹都有一些齐普文件。

现在,我要制作一个批号,以复制所有子夹中包含<条码>Win的所有单体。 来源途径是F:/_QAPrivate,目的地为F:_QAips

I initially tried just for testing to copy all the zips using

XCOPY F:\_QAPrivate F:\_QAips

which didn t seem to work.

问题回答

You ll want to use the dir command which can output all zip files recursively, and then filter the output and copy the results. Here is a tested script that does just that:

@echo off

set "fromPath=F:\_QAPrivate"
set "destinationPath=F:\_QAips"

if not exist "%destinationPath%" mkdir "%destinationPath%"

:: The findstr is to filter a case sensitive "Win", as the dir command
:: is always case-insensitive. Feel free to remove that part.
for /f "delims=" %%A in ( dir "%fromPath%*.zip" /b /s ^| findstr /r /c:"\[^^\]*Win[^^\]*\[^^\]*.zip$" ) do (
    echo Copying "%%A"...
    copy /y "%%A" "%destinationPath%" > NUL
)

echo.
echo Complete!
pause

First we find all zip files recursively in that folder, then we filter the output with a the following regex expression:

\[^^\]*Win[^^\]*\[^^\]*.zip$

这只过滤了直接在带<代码>的子里面的齐p文档。 Win 。

See dir and findstr for more details regarding those commands.





相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签