I have two folder 1
and 2
. i save file list name in text C:\a\filelist.txt
. file list contains files are available in folder 1
which i want to move files from folder 1
to 2
using the file list from the text.
@echo off
move C:\a\1\"new.txt" C:\a\2
pause
Here's a batch-file option, which uses the built-in findstr executable to check against the files listed in the text file:
@For /F "EOL=| Delims=" %%# In (
'Dir /B /A:-D "C:\a\1" ^| "%__AppDir__%findStr.exe" /E /L /I /G:"C:\a\filelist.txt"'
) Do @Move /Y "C:\a\1\%%#" "C:\a\2"
Here's a shortened, single line Command Prompt, ( cmd ) , version:
For /F "EOL=|Delims=" %# In ('Dir /B/A-D "C:\a\1"^|FindStr /ELIG:"C:\a\filelist.txt"')Do @Move /Y "C:\a\1\%#" "C:\a\2"
This assumes that both your %PATH%
and %PATHEXT%
variables still hold their appropriate default values, or findstr.exe
is located in the current directory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.