Page 1 of 1

Recursively search in sub folders and move files

Posted: 06 Jan 2014 15:34
by Danny
Hi,

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.

Re: Recursively search in sub folders and move files

Posted: 06 Jan 2014 19:18
by foxidrive
Please provide better details for the filenames

Re: Recursively search in sub folders and move files

Posted: 06 Jan 2014 22:02
by Danny
foxidrive wrote:Please provide better details for the filenames


Thankyou very much for your response.

The description of file name 1.
For files type 1 it will not have duplicates why all the upload folders will deliver different names files.
1*ddmm.txt means 1 is type of report and its compulsory
----------- next is * means first 3 character of file name which can be VAT,RPT,SLR,STT, ....
----------- and day&month.
1VAT0701.txt, 1RPT0701.txt, 1SLR0701.txt

File type 2 will be dupicated that means from every upload this file TR(means transaction) files will be delivered in upload folder.
TRddmm.txt means TR common tag and next is day&month

Re: Recursively search in sub folders and move files

Posted: 06 Jan 2014 22:12
by foxidrive
Why is it that you didn't give feedback in this thread? viewtopic.php?f=3&t=5225

Re: Recursively search in sub folders and move files

Posted: 06 Jan 2014 22:27
by Danny
foxidrive wrote:Why is it that you didn't give feedback in this thread? viewtopic.php?f=3&t=5225


Its perfect, Infact i wanted to hide myself, you will say how many question this fellow is asking.

Its perfect and thats made me to asked this question, i have always got the answers from this forum

Re: Recursively search in sub folders and move files

Posted: 08 Jan 2014 06:18
by Danny
Hi Foxidrive, Please help!

Re: Recursively search in sub folders and move files

Posted: 08 Jan 2014 06:35
by foxidrive
When people help, they really do expect a simple 'thanks' and to find out if the code worked or not.
It's not too much to ask and isn't unreasonable.

It's unfortunate that in recent years a lot of people accept this free help and don't bother replying, unless they need some changes or have another problem.

Re: Recursively search in sub folders and move files

Posted: 08 Jan 2014 06:59
by Danny
Hi,

My apologies, foxidrive i will not repeat this in future.