Home > OS >  DOS for use cases subtotal command
DOS for use cases subtotal command

Time:10-13

Today is a long seen in Windows explorer, nearly 50 multiple folders to operate, to copy all the files in another directory to each of the 50 multiple folders folder, is my baby! Manual operation, at least one by one opened more than 50 folder, and then one by one, the Paste, mechanical work dead tired people!

Is there any easy way? Anyway, there is no such software can do it, the command line should be ok, yes, you can use the command line for the command to be realized,

First of all, the superior directories of the folders in the more than 50, hold down the shift key, and then right-click, in the pop-up menu, click here to open a command window, a command prompt then opened, and has cut the superior directories of the folders to more than 50,

Directly from the command line for executive orders, below my command is as follows:
 
Setlocal enabledelayedexpansion
For/f % s in (' dir/a, d/b ') do (
1 copy/y c: \ \ *. * % s
)
Endlocal


Efficiency, it is a great, if you have the same demand, can also refer to try! I hope it can help you,

CodePudding user response:

Thanks for sharing! ~ ~

CodePudding user response:

That study, thanks for sharing,

CodePudding user response:

The building Lord, you are under the software in the folder to share

CodePudding user response:

Thanks for sharing ~ ~ study

CodePudding user response:

C: \ & gt; for/?
For each file in a set of files for a particular command,

FOR % variable (set) IN the DO command [command - the parameters]

% variable specifies a single letter replaceable parameters,
One or a set of specified file (set), can use a wildcard,
The command for each file specified command execution,
The command - the parameters
Specify parameters for specific command or command line switch,

Used in the batch program FOR orders, please use the specified variable % % variable
And don't use % variable, variable names are case sensitive, so % is different from % i. I

If the command extension is enabled, the following additional FOR the command format will be
Support:

FOR/D % variable (set) IN the DO command [command - the parameters]

If the set contains wildcards, specify and directory name matches, but not with the file
A match,

Path FOR/R [[drive:]] % variable (set) IN the DO command [command - the parameters]

Check to/drive: the path to the root directory tree, to each directory
FOR statement, if after a/R do not specify a directory, use the current
Directory, if only for a single dot (.) characters, has enumerated the directory tree,

FOR/L % variable IN (start, step, end) DO command [command - the parameters]

The set said in incremental form a sequence of Numbers from start to finish,
,1,5 (1), therefore, will produce the sequence 1, 2, 3, 4, 5 (5, 1, 1) will produce
Sequence (5 4 3 2 1),

FOR/F [" options "] % variable (file - set) DO command IN [the command - the parameters]
FOR/F [" options "] % variable (" string ") DO the command IN [the command - the parameters]
FOR/F [" options "] % variable (' command ') IN the DO command [command - the parameters]

Or, if you have usebackq options:

FOR/F [" options "] % variable (file - set) DO command IN [the command - the parameters]
FOR/F [" options "] % variable (" string ") DO the command IN [the command - the parameters]
FOR/F [" options "] % variable (' command ') IN the DO command [command - the parameters]

Filenameset for one or more of the file name, to continue into the filenameset
Before the next file, each file has been opened, read and processed,
Processing including read the file, it is divided into a line of words, then each row
Parsed into zero or more of the symbol, then use has found a symbol string variable values
Call For loop, in the default/F way through each line of each file in separate
First whitespace, skip the blank lines, you can by specifying an optional
"options"Parameters instead of the default parsing operations, the quoted string includes one or more
Specify different resolution option keywords, these keywords is:

Eol=c - refers to a comment line character at the end of the (a)
The skip=n - refers to at the beginning of the file to ignore the number of rows,
Delims=XXX - refers to the delimiter is set, the replaced the Spaces and TAB keys
The default delimiter sets,
Tokens=x, y, m - n - refers to which a symbol of the row is passed to each iteration
For itself, which leads to the allocation of additional variable names, m - n
Format for a scope through the NTH symbols to specify MTH, if
Last the asterisk character symbols in the string,
Additional variables will be after the last symbol resolution
Distribution and accept the reservation text,
Usebackq - specify the new syntax has been put in use next class situation:
Quotes after as a command to execute a string and a single
Quote character and allow for literal string commands in filenameset
Enlarge the file name used in double quotation marks,

Some example may help:

FOR/F "eol=; Tokens=2, 3 * delims="% I in (myfile. TXT) do @ echo % I % j % k

Will analyze myfile. TXT in each line, will ignore the line that starts with a semicolon,
Each row of the second and third symbol is passed to the for body; With a comma and/or
Whitespace delimited symbol, please note that this for body statement quoted % I to
Obtain the second symbol, reference % j for the third symbol, reference % k
To achieve the third symbol after all remaining symbols, with space for file
Name, you need to use double quotation marks will be enclosed file name, in order to use this way to
Use double quotation marks, you also need to use the usebackq option, otherwise, double quotes will
Understood as is used to define a string to analyze,

% I specialized in instructions for statement, % % j and k by
Tokens=option specifically get instructions, you can use tokens=line
Specify up to 26 symbols, as long as you don't try to show a higher than the letters' z 'or
Variables' Z ', remember that the FOR a variable is a single letters, capitalization and global; Moreover,
At the same time can't more than 52 are in use,

You can also use FOR/F on adjacent strings analysis logic; Method is,
Use single quotation marks between the brackets filenameset enclosed, in this way, the characters
Served as a file of a single input line,

Finally, you can use FOR/F command to analyze the output of the command, the method is,
Between the brackets filenameset into an enclosed string, the string will be
Be used as a command line, pass to a child CMD. EXE, the output will be put into
Memory, and treated as document analysis, therefore, the following example:

FOR/F "usebackq delims==" % I IN (` set `) DO @ echo I

Are enumerated the environment variable's name in the current environment,

In addition, the reference FOR variable replacement has been enhanced, you can now use the following
Option syntax:

~ I - delete any quotation marks ("), extended % I
% % ~ fI - will I extended to a fully qualified path name
% % ~ dI - only I extended to a drive letter
% % ~ pI - only I extended to a path
% % ~ nI - only I extended to a file name
% % ~ xI - only I extended to a file extension
% ~ sI - extension path contains only short name
% % ~ aI - will I extended to file the file attributes of the
% % ~ tI - will I expand to the file date/time
% % ~ zI - will I extension to the file size
% ~ $PATH: I - find listed in the directory PATH environment variable, and the extension of the % I
To find the first fully qualified name, if the environment variable name
Has not been defined, or could not find file, this key combination would expand to
An empty string

Can combine modifiers to get multiple results:

% % ~ dpI - only I extended to a drive letter and path
% % ~ nxI - only I spread to a file name and extension
% % ~ fsI - only I extended to a full pathname with short name
% ~ dp $PATH: I - search listed in the directory PATH environment variable, and the extension of the % I
To find the first drive and path,
% % ~ ftzaI - will be extended to similar I output line DIR

In the above example, % I and PATH can be replaced other effective numerical, % ~ syntax
With a valid FOR the variable name is terminated, select similar % I capital variable name
More easy to read, and avoid confused with key combination of case insensitive,

  • Related