Moving files containing certain words
Posted: 04 Aug 2013 11:02
I am in need of a batch script that will move files containing certain words from one folder to another, all while keeping the same folder structure. From what I gather online, I have found the following script and it does not seem to be working. Any help would be greatly appreciated!
@echo off
setlocal enabledelayedexpansion
set SOURCE_DIR=C:\Source
set DEST_DIR=C:\Destination
set FILENAMES_TO_COPY=data.zip info.txt
for /R "%SOURCE_DIR%" %%F IN (%FILENAMES_TO_COPY%) do (
if exist "%%F" (
set FILE_DIR=%%~dpF
set FILE_INTERMEDIATE_DIR=!FILE_DIR:%SOURCE_DIR%=!
xcopy /E /I /Y "%%F" "%DEST_DIR%!FILE_INTERMEDIATE_DIR!"
)
)
@echo off
setlocal enabledelayedexpansion
set SOURCE_DIR=C:\Source
set DEST_DIR=C:\Destination
set FILENAMES_TO_COPY=data.zip info.txt
for /R "%SOURCE_DIR%" %%F IN (%FILENAMES_TO_COPY%) do (
if exist "%%F" (
set FILE_DIR=%%~dpF
set FILE_INTERMEDIATE_DIR=!FILE_DIR:%SOURCE_DIR%=!
xcopy /E /I /Y "%%F" "%DEST_DIR%!FILE_INTERMEDIATE_DIR!"
)
)