How can I search and copy files using a .bat file?
5,321
This batch script will help you achieve what you're after
@ECHO OFF
SET /P drive="Enter the drive letter"
FOR /R "%drive%:\" %%G IN (*.txt) DO (
ECHO COPY %%G W:\RestorePoint\%%~nG
)
I'm assuming in this script that the restore directory is "W:\RestorePoint" which is a directory that needs to be created prior to running the script.
Related videos on Youtube
Author by
Anderson Oliveira
Updated on September 18, 2022Comments
-
Anderson Oliveira over 1 year
I would like to search for all .txt files from a computer drive and copy them to a specific folder using a batch file.
-
fixer1234 over 8 yearsYou're talking about recursing through all directories on the drive and copying all .txt files to a single folder on another drive?
-
Anderson Oliveira over 8 yearsYes, that's what I want.
-
-
Dhiwakar Ravikumar over 8 yearsIf you felt my answer was helpful please mark it and upvote it :) Thank you