Recursively search in sub folders and move files
Posted: 06 Jan 2014 15:34
Hi,
This codes are moving the files from soruce folder to destination perfectly.
But now i want this codes to search recursively in multiple sub-folders. The folder structure is in this format.
C:\Repository\000\todays date(dd-mm-yyyy)\upload\file1 and file2
C:\Repository\001\todays date(dd-mm-yyyy)\upload\file1 and file2
C:\Repository\002\todays date(dd-mm-yyyy)\upload\file1 and file2
To move the files from this sub folder upload to D:\report search for files every 60 seconds.
The first file will never be in duplicate so no issue of overwriting the file in destination folder, but the second file can be duplicate so how to overcome that issue. can we create a merge file in destination folder. They are text files.
Sorry for asking to much.
This codes are moving the files from soruce folder to destination perfectly.
Code: Select all
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%DD%%MM%"
for /l %%a in (0) do (
if exist "C:\test\1*%datestamp%.*" move "C:\test\1*%datestamp%.*" "D:\report"
if exist "C:\test\TR%datestamp%.*" move "C:\test\TR%datestamp%.*" "D:\report"
ping -n 60 localhost > nul
)
But now i want this codes to search recursively in multiple sub-folders. The folder structure is in this format.
C:\Repository\000\todays date(dd-mm-yyyy)\upload\file1 and file2
C:\Repository\001\todays date(dd-mm-yyyy)\upload\file1 and file2
C:\Repository\002\todays date(dd-mm-yyyy)\upload\file1 and file2
To move the files from this sub folder upload to D:\report search for files every 60 seconds.
The first file will never be in duplicate so no issue of overwriting the file in destination folder, but the second file can be duplicate so how to overcome that issue. can we create a merge file in destination folder. They are text files.
Sorry for asking to much.