Need to copy Files generated for last 1 hour

Microsoft Windows xp professional editio...
October 28, 2009 at 23:04:03
Specs: Windows XP
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.


See More: Need to copy Files generated for last 1 hour

Report •


#1
October 29, 2009 at 00:41:17
Run this script and post a few lines of the output.

===============================
@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
echo %%~Ta
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
October 29, 2009 at 11:04:16
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


Report •

#3
October 30, 2009 at 02:06:06
@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 felicity

M2


Report •

Related Solutions

#4
November 5, 2009 at 07:12:18
WARNING to the surfers: the question was answered via private messages.

Report •

#5
November 5, 2009 at 07:45:01
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?

Report •

#6
November 6, 2009 at 06:53:21
ace,

LOL What I posted works. Nothing heard from OP.


=====================================
Helping others achieve escape felicity

M2


Report •

#7
November 6, 2009 at 07:00:17
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?


Report •

#8
November 6, 2009 at 07:33:02
"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 felicity

M2


Report •

#9
November 6, 2009 at 07:35:40
Ok, so the bangs are key. Thanks for the help.

Report •


Ask Question