# Solved: Copy files date modified today to subfolder that generates today



## etstalker (Sep 30, 2012)

Dear All,

I have problem to copy all files *.txt generated every days by systems, so I decided to wrote batch files. My Problem is :
How to copy files *.txt as today date modified from one folder to subfolders (same drive).

Example :
Source path files *.txt in folder 
D:\archive
Destination path :
D:\omega\log\tptes\txt

In subfolder txt, there is folders generates everydays (so date modified absolutely when it generates).
Like this :
D:\omega\log\tptes\txt\*20120930*

*20120930* is subfolder that generates today, tomorrow, there is folder's name *20121001* and continues every day.

I want to copy files *.txt (*.txt files date modified/generated today) from source path files *.txt in folder D:\archive to D:\omega\log\tptes\txt\*20120930*, and tomorrow too.

If you dont mind and take the time to coding it.

Thanks before


----------



## Paata01 (Sep 30, 2012)

try to change name or the file you want to copy and rename on original version later, sometimes it works.


----------



## etstalker (Sep 30, 2012)

Dear Paata01,

Thanks for your reply, but its difficult for me to change the name of the files, because there's reasons about the name of the files is identity of log file *.txt.


----------



## Squashman (Apr 4, 2003)

What version of Windows are you running?

Open up a CMD prompt and type the following command:
*echo %date%*
Please post the output.


----------



## etstalker (Sep 30, 2012)

Dear Squashman,

Thanks for your concern.

Win 7, my date format is dd/mm/yyyy,

I coding until here now

@echo off & setlocal enabledelayedexpansion
set arch=d:\archive
cd /d %arch%
set rev=%date:~-4%%date:~3,2%%date:~0,2%
set dest=D:\omega\log\tptes\txt
cd /d %dest%>%rev%

Now, i have problem to copy files *.txt that generates today in d:\archive to %dest%>%rev%

Thanks before.


----------



## Squashman (Apr 4, 2003)

I asked for the output. If you cannot comply with that request then I cannot help you.


----------



## etstalker (Sep 30, 2012)

Dear Squashman,

Thanks for your fast reply,

this is the output 01/10/2012


----------



## Squashman (Apr 4, 2003)

XCOPY and FORFILES have a /D switch to specify a date.


----------



## etstalker (Sep 30, 2012)

Dear Squashman,

Thanks for your reply, thats not spesific.

But I never got it after I debug my command, I hope I can copy today's file to today's folder or any files to today's folder.

I think, I'm done for today

Thanks again for your concern.


----------



## Squashman (Apr 4, 2003)

What is not specific enough for you? I told you two commands you can use. All you need to do is look at the help for the exact syntax. If you are not using Xcopy or Forfiles with the date option I have no idea how you could possibly copy all files modified today.

When you mark your thread solved you should post all the code that solved your issue.


----------



## Squashman (Apr 4, 2003)

Hard to help when you are not showing us all the code you are using.


----------



## etstalker (Sep 30, 2012)

etstalker said:


> Dear Squashman,
> 
> Thanks for your concern.
> 
> ...


Dear Squashman,

Above what the last I'm coding,

Thanks.


----------



## Squashman (Apr 4, 2003)

I kind of was expecting you to at least attempt to use xcopy in your script.


----------



## etstalker (Sep 30, 2012)

I Got This from others forum and its worked, with debug it little bit.

@echo off & setlocal enabledelayedexpansion
set arch=c:\duplicate
cd /d %arch%
set rev=%date:~-4%%date:~4,2%%date:~7,2%.bat
set dest=D:\gemscol\key\voucher\normal
:: this builds the "reverse-engine" batch based on date of the archive-run
cd /d %dest%>%rev%
for /f "tokens=*" %%a in ('dir /s /b *.txt') do (
:: build the reverse-engine batch
>> %rev% echo copy /y %arch%\%%~nxa %%a
:: now copy/move
copy /y %%a %arch%
)
::===== end

Thanks all


----------

