How to copy files with a specific pattern? -
I have some folders that contain at least one zip file, though there may be more zip files in this folder. Looks like:
Parents | + - X7G 000738512 | | | `- X7G000738512_20141028_1210.zip | + - X7G000843295 | | | + - X7G000843295_20141028_1210.zip | | | `- X7G000843295_20141028_1210_OLD.zip | + - x7 g 000482756 | | | + - X7G000482756_20141028_1210.zip | | | `- X7G000482756_20141028_1210_UGLUT.ZIP | `- X7G000285672 | + - X7G000285672_20141028_1210.zip | + - X7G000285672_20141028_1210_OLD.zip | `- x7g000285672_20141028_1210_Unglutiz.zip
Now I want to copy the zip-files that do not end in" _old "or" _ungueltig "root directory. How can I accomplish this task?
@echo off setlocal enableextensions Disabled expense set "target = c: \" somewhere Also \ "for \" / f "delims =" %% a in ('dir / s / b / ad'% target% * * zip) ^ | SearchR / R / I / C: "% Target: \" = \\% \\ [^ \\] * \\. %% ("%% ~ A" "%% ~ FB") for "^ | searchr / L / V / I / E / c: ___ zip" /c:"_ungueltig.zip "')
This uses a dir The command to get the full list of zip files, which is
command files do not contain Findstr
, to process files only under the subdirectory (not the process file in the target folder), and the rest list is only filtered into the process which can be encapsulated String list process %% a , and for each one,
copy
command is executed.
I was not sure about this in the parent
in the question, therefore, in this code parent
is determined by the folder where .zip file is stored. To determine the place to copy this file, the reason for
%% b
is.
If there is a parent
folder % target%
folder, remove for the last and use
.... ^ | "%% ~" "% target%") /