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,