Home > Software engineering >  According to the file name batch search keywords list, move files and copy the corresponding folder,
According to the file name batch search keywords list, move files and copy the corresponding folder,

Time:09-15

@ echo off
Md e: \ search output file
For/f "delims=" % % a in (search listings. TXT) do (
For/f "delims=" % % b in (' dir/a - d/b/s (e: \ drawings') do (
Set "STR=% % ~ nb"
Setlocal enabledelayedexpansion
If not "! STR: a=% %!"=="! STR!" (endlocal & amp; Move the "% % b" e: \ search output file)
Endlocal
)
)
Pause

Everybody is good, the above procedure on the basis of other warrior for me (see: http://www.bathome.net/thread-39929-1-1.html) together, to achieve "according to the file name batch search keywords list, move the file" but can't achieve the following functions:
1, copy the corresponding folder, that is, to avoid all of the files tile under the search output file "e: ";
2, the file has repeatedly remind.

Which master can help achieve these two functions? Thank you very much,

CodePudding user response:

Article 2 above if compare to "date", "size" and shows better

CodePudding user response:

You're going to use vb to handle?

CodePudding user response:

Proposed to bat grammar to VBS,

CodePudding user response:

 @ echo off 
SETLOCAL EnableDelayedExpansion

SET "v_CD=% % CD"
PUSHD
CD e: \ drawing \

For/f "delims=" % % a in (% v_CD % \ search listings. TXT) do (
For/f "delims=" % % b in (' dir/a - d/b/s % % ') do (
Set "STR=% % b"
"Move" % % b! "" STR: e: \ \ drawing=e: \ \ to search for the output file!"
)
)

The POPD

The set v_CD=
Set the STR=

ENDLOCAL

The % % a directly as a lookup parameters (file name),
Because recursive search parameters not specified file name and the initial directory at the same time, so let's set the starting directory for the current directory,
Using variable string substitution to retain the directory information in the target,

Function is implemented, 1
2 don't need to function after a subdirectory,

CodePudding user response:

Thank you, I don't know how to can't achieve?

CodePudding user response:

refer to the second floor Topc008 response:
do you want to use vb to deal with?


With what can be, as long as can realize functions

CodePudding user response:

reference 4 floor Tiger_Zhao response:
 @ echo off 
SETLOCAL EnableDelayedExpansion

SET "v_CD=% % CD"
PUSHD
CD e: \ drawing \

For/f "delims=" % % a in (% v_CD % \ search listings. TXT) do (
For/f "delims=" % % b in (' dir/a - d/b/s % % ') do (
Set "STR=% % b"
"Move" % % b! "" STR: e: \ \ drawing=e: \ \ to search for the output file!"
)
)

The POPD

The set v_CD=
Set the STR=

ENDLOCAL

The % % a directly as a lookup parameters (file name),
Because recursive search parameters not specified file name and the initial directory at the same time, so let's set the starting directory for the current directory,
Using variable string substitution to retain the directory information in the target,

Function is implemented, 1
2 don't need to function after a subdirectory,

Thank you for your advice, how can't test implementation?

CodePudding user response:

Try change drive e: to capital, the content of the string substitution to Dir results of path matching with you,

CodePudding user response:

refer to the eighth floor Tiger_Zhao response:
drive e: try to capital, the content of the string substitution to Dir results of path matching with you,


Thank you, not achieve them it is changed to uppercase

CodePudding user response:

You move it into a
 ECHO move! "" STR!" ! "" STR: E: \ \ drawing=E: \ \ to search for the output file!" 

The output content is copied to a bat file, execution, and behold a mistake,

CodePudding user response:

The
references to the tenth floor Tiger_Zhao response:
you to move this sentence to
 ECHO move! "" STR!" ! "" STR: E: \ \ drawing=E: \ \ to search for the output file!" 

The output content is copied to a bat file, execution, and behold a mistake,


Hello, see attachment.

CodePudding user response:

Perform the bat! Alone there are birds use a!

CodePudding user response:

C: \ & gt; set/?
, according to a set or delete the CMD. Exe environment variables,

The SET [variable=[string]]

Environment variable specifies the variable name,
A series of string string specified to be assigned to a variable,

To show the current environment variables, type with no parameters SET,

If the command extension is enabled, the SET will change as follows:

Can use only one variable to activate the SET command, equal or values do not show all prefix matching
The SET command is to use the name of the values of all variables, such as:

The SET P

Displays all the variables that starts with a P

If can't find the variable name in the current environment, the SET command will put the ERRORLEVEL
Set to 1,

SET command does not allow variable names contain the equal sign,

In the SET command added two new command line switch:

The SET/A expression
The SET/P variable=[promptString]

/A command line switch to specify the number of the right hand side of the string to be evaluated expression, the expression
Assessment is simple and to the priority order of decreasing supports the following operations:

Group
() -! ~ - unary operator
*/% - arithmetic operator
+ - arithmetic operator
<> - logical shift
& - according to a "and"
^ - according to a "different"
| - according to a "or"
=*=/=%=+=-=- assignment
&=^=|=& lt; <=& gt;>=
- expression delimiters

If you use any logical or operator, you need to use expression string
Quotes, expanding the expression of any non numeric string keys as environment variable
The value of the name, the name of these environment variables has been converted to digital before use, if you specify a
The name of an environment variable, but is not defined in the current environment, then the value will be classified as
Zero, which allows you to use the environment variable values do calculation without having to type in the % symbol
To get their values, if the SET/A in the command line outside the command scripts executed,
It showed that the expression of the final value, the allocation of operators in the allocation of operator
The left require an environment variable name, in addition to the hex 0 x prefix, octal
Have 0 prefix, numeric values for the decimal Numbers, therefore, 0 x12 and 18 and 022
The same, please note octal formula could easily confused: 08 and 09 is invalid number,
Because of 8 and 9 is not a valid octal digits,

/P command line switch allows the numerical set user input variables of a line of input, read input
Line before, according to the specified promptString promptString can is empty,

Environment variable substitution is enhanced as follows:

% % PATH: str1=str2

Will expand the PATH environment variable, using "str2" instead of extending the results of each "str1,"
To effectively removed from the result of extending all the "str1", "str2 can is empty,"
"Str1" with an asterisk can; In this case, the "str1" from extended results of
Appear for the first time to the str1 rest place, has been to keep suitable,

Can also specify the substring for extension,

% % PATH: ~ 10, 5

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related