Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi Guys,
Am new to this forum and new in writing batch scripts. Need some help to the below -
Need to create a .bat [schedule task] file for performing below -
1. Search for the files that are generated in last hour
2. Copy last hour generated files from one location to another.This script will be scheduled to run every hour to keep copying files generated in past 1 hour.

Run this script and post a few lines of the output.
===============================
@echo off > newfile & setLocal enableDELAYedexpansionfor /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
echo %%~Ta
)
=====================================
Helping others achieve escape felicityM2

Hi M2, Thanks for help...
Here is the output - ran @ 11:35PM IST
29-10-2009 23:34
29-10-2009 23:34
29-10-2009 23:34
01-05-2009 12:32
29-10-2009 19:54
29-10-2009 19:54
20-10-2009 17:52
19-10-2009 18:19
19-10-2009 18:19
01-05-2009 12:53
21-01-2008 07:12
26-07-2009 18:04
15-10-2009 22:12
29-10-2009 23:34

@echo off & setLocal EnableDELAYedExpansion
@echo off > %temp%\#
for /f "tokens=* delims= " %%a in ('dir/s/b %temp%\#') do (
set T=%%~Ta
set C=!T:~11,2!
)for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set T=%%~Ta
set H=!T:~11,2!
if !H! equ !C! (
copy %%a d:\dest
)
)
=====================================
Helping others achieve escape felicityM2

Ok so what was the answer because I am working on a simpler project and can not get the %%A to go to another variable so I can pars the dates and times?

ace,
LOL What I posted works. Nothing heard from OP.
=====================================
Helping others achieve escape felicityM2

Actually it does not work. This command...
set T=%%~Ta
does not set T to any thing and if you echo it it just says echo is off. Here is the code I am using to test with...
@echo off & setLocal EnableDELAYedExpansion @echo off > %temp%\# for /f "tokens=*" %%a in ('dir/s/b') do ( set T=%%~Ta set C=!T:~11,2! Echo %T% Echo %C% Pause )Can you tell me what is wrong?

"does not set T to any thing"
LOL
===========================
@echo off & setLocal EnableDELAYedExpansion
@echo off > %temp%\#
for /f "tokens=*" %%a in ('dir/s/b') do (
set T=%%~Ta
set C=!T:~11,2!
Echo !T!
Echo !C!
)
=====================================
Helping others achieve escape felicityM2

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |