Upload
allan-lobo
View
217
Download
0
Embed Size (px)
Citation preview
8/13/2019 Copy Files Modified In Last Hour Batch.pdf
1/8
Copy Files Modified In Last Hour Batch
Tags:DOS
batch
Windows
Score
1
dngoodFebruary 25, 2010 at 02:00:29 Pacific
Specs: Windows XP
I wish to create a batch file which will copy image files created in the last hour to anotherfolder. Note I only want to copy files with a .jpg extension.
Can anyone help with this?
Reply Report Share on facebookShare on twitterShare on google_plusone
Share on emailMore Sharing Services
Ads by Google
AD Group Membership
Automate add/remove of Active Directory Members with policy.
www.condreycorp.com/Groupsymmetry
#1
Score
0
tvcFebruary 25, 2010 at 03:41:19 Pacific
It can easily be done in fact, step 1 is to have a tool that can behold the current time and
date, into parameters.
Do you have that ?
If not - and this is a question towards the expert - do we here at Computing.net have some
kind of single reference for such things ?
http://www.computing.net/tags/dos/104/http://www.computing.net/tags/batch/125/http://www.computing.net/tags/windows/48/http://www.computing.net/userinfo/234507http://www.computing.net/userinfo/234507http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=tomsguide&source=tbx-250&lng=es&s=linkedin&url=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fcopy-files-modified-in-last-hour-batch%2F20948.html%23xtor%3DRSS-995&title=Copy%20files%20modified%20in%20last%20hour%20batch&ate=AT-tomsguide/-/-/506270c12d941073/2&frommenu=1&uid=506270c11a489eca&pre=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fmove-the-oldest-file-by-last-modifi%2F14474.html&tt=0&captcha_provider=nucaptchahttp://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=tomsguide&source=tbx-250&lng=es&s=linkedin&url=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fcopy-files-modified-in-last-hour-batch%2F20948.html%23xtor%3DRSS-995&title=Copy%20files%20modified%20in%20last%20hour%20batch&ate=AT-tomsguide/-/-/506270c12d941073/2&frommenu=1&uid=506270c11a489eca&pre=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fmove-the-oldest-file-by-last-modifi%2F14474.html&tt=0&captcha_provider=nucaptchahttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.addthis.com/bookmark.php?v=250&username=tomsguidehttp://www.addthis.com/bookmark.php?v=250&username=tomsguidehttp://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html%26gl%3DHN%26hl%3Den%26client%3Dca-pub-8792502999873740%26ai0%3DCHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&usg=AFQjCNFviUt4hjC4xtrXJaOICTd6PPR0Qghttp://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html%26gl%3DHN%26hl%3Den%26client%3Dca-pub-8792502999873740%26ai0%3DCHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&usg=AFQjCNFviUt4hjC4xtrXJaOICTd6PPR0Qghttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://googleads.g.doubleclick.net/aclk?sa=L&ai=CHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&num=1&sig=AOD64_2TnxGv1pIfnBV5Hg0lUrTFoxxLww&client=ca-pub-8792502999873740&adurl=http://www.condreycorp.com/Groupsymmetryhttp://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html%26gl%3DHN%26hl%3Den%26client%3Dca-pub-8792502999873740%26ai0%3DCHvlaynBiUMKVLaqZ6gGK5YCYBcXk7_QCnZ7b0DHAjbcBEAEg3pO_A1CkiaisBWDVAsgBAagDAaoEkAFP0Aw3EXlJq1O90ErKM3To4pymIVGMKAcR2uHLuSaO4hVWWXcD7zpl1HPX495rDvQU91WL1LSpgmS7d4lhV-b-9uY-1jenPECHdizb5ZbkLqW2pTD1foJrWlD0QccZsG2C8ilTIaFRU8CXikH-rySwS96jyW2IsOe9WNL05ye237bAaPnWURy-I77hAa4gBqc&usg=AFQjCNFviUt4hjC4xtrXJaOICTd6PPR0Qghttp://www.addthis.com/bookmark.php?v=250&username=tomsguidehttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=tomsguide&source=tbx-250&lng=es&s=linkedin&url=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fcopy-files-modified-in-last-hour-batch%2F20948.html%23xtor%3DRSS-995&title=Copy%20files%20modified%20in%20last%20hour%20batch&ate=AT-tomsguide/-/-/506270c12d941073/2&frommenu=1&uid=506270c11a489eca&pre=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fmove-the-oldest-file-by-last-modifi%2F14474.html&tt=0&captcha_provider=nucaptchahttp://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=tomsguide&source=tbx-250&lng=es&s=linkedin&url=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fcopy-files-modified-in-last-hour-batch%2F20948.html%23xtor%3DRSS-995&title=Copy%20files%20modified%20in%20last%20hour%20batch&ate=AT-tomsguide/-/-/506270c12d941073/2&frommenu=1&uid=506270c11a489eca&pre=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fmove-the-oldest-file-by-last-modifi%2F14474.html&tt=0&captcha_provider=nucaptchahttp://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=tomsguide&source=tbx-250&lng=es&s=linkedin&url=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fcopy-files-modified-in-last-hour-batch%2F20948.html%23xtor%3DRSS-995&title=Copy%20files%20modified%20in%20last%20hour%20batch&ate=AT-tomsguide/-/-/506270c12d941073/2&frommenu=1&uid=506270c11a489eca&pre=http%3A%2F%2Fwww.computing.net%2Fanswers%2Fprogramming%2Fmove-the-oldest-file-by-last-modifi%2F14474.html&tt=0&captcha_provider=nucaptchahttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.htmlhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/234507http://www.computing.net/tags/windows/48/http://www.computing.net/tags/batch/125/http://www.computing.net/tags/dos/104/8/13/2019 Copy Files Modified In Last Hour Batch.pdf
2/8
Reply Report
#2
Score
0
Razor2.3March 1, 2010 at 12:54:02 Pacific
tvc:do we here at Computing.net have some kind of single reference for such things ?
The general consensus is that date math in CMD sucks. What we do about it depends on theguy answering the question. Some will use debug.exe to write a .COM file; others (me) will
suggest VBScript; the rest typically suggest a third party language. If Win7 is involved,
POWERSHELL! would technically be a valid alternative.
No one has bothered to write any of this down in a central source.
Reply Report
#3
Score
0
tvcMarch 1, 2010 at 14:32:55 Pacific
I would agree, apart from the last line. I'm sure somebody would have, but it's a matter of
getting that one being recognized, and used.
Threastarter : still alive ?
Reply Report
#4
Score
0
nbraneMarch 1, 2010 at 16:53:01 Pacific
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/15853http://www.computing.net/userinfo/15853http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/215180http://www.computing.net/userinfo/215180http://www.computing.net/userinfo/215180http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/137440http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/15853http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp8/13/2019 Copy Files Modified In Last Hour Batch.pdf
3/8
actually, in this case, since it's time and not date, you could probably just let AT do most ofthe work. set up the bat to reschedule itself for +1hour after running the copy operation.
time is not as hard to deal with as dates.
@op: if interested in script to add time to current time, let me know, i wrote one for
something else awhile back and it's still laying around.
"No one has bothered to write any of this down in a central source."@Razor, thats a good idear, if 'someone' would set something up like a faq or "how-to"
page, but we'll probably just keep improvising and muddle through! :(
Reply Report
Related Posts
Delete folder in batch script Batch script copy folder Batch copy files to folder [Solved] Batch copy last modified file
See More
#5
Score
0
tvcMarch 2, 2010 at 05:33:40 Pacific
Time is definatly easier, indeed.
I like the solution you posted Nbrane, but keep in mind that it does have some serious
drawbacks, and the biggest one being the fact that the script itself (that what you put into
the scheduling) does NOT contain the 1-hour rule.
You are allowing the wrapper (super-script feature, by means of scheduler) take over thattask. Now, if that one fails (scheduler down, server down, scheduler blocked, ...) the script
itself may behave weird on it (and basically, not take only the files within the 1-hour rule).
You must always have any constraint, as close to the core as possible, so that any runningof it, uses that constraint.
Dngood, if you want to, I'll write a script to help you with it. But, there's a catch, being thatI will rely on other scripts I have (the ones handling the time), so in other words, it'll be a
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/script-to-maintain-files-in-folders/16780.htmlhttp://www.computing.net/answers/programming/script-to-maintain-files-in-folders/16780.htmlhttp://www.computing.net/answers/programming/script-to-maintain-files-in-folders/16780.htmlhttp://www.computing.net/answers/programming/batch-copy-filesfolders-from-txt/23803.htmlhttp://www.computing.net/answers/programming/batch-copy-filesfolders-from-txt/23803.htmlhttp://www.computing.net/answers/programming/batch-copy-filesfolders-from-txt/23803.htmlhttp://www.computing.net/answers/programming/batch-copy-unmatching-files/17123.htmlhttp://www.computing.net/answers/programming/batch-copy-unmatching-files/17123.htmlhttp://www.computing.net/answers/programming/batch-copy-unmatching-files/17123.htmlhttp://www.computing.net/answers/programming/batch-copy-last-x-modified-files/25825.htmlhttp://www.computing.net/answers/programming/batch-copy-last-x-modified-files/25825.htmlhttp://www.computing.net/answers/programming/batch-copy-last-x-modified-files/25825.htmlhttp://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/answers/programming/batch-copy-last-x-modified-files/25825.htmlhttp://www.computing.net/answers/programming/batch-copy-unmatching-files/17123.htmlhttp://www.computing.net/answers/programming/batch-copy-filesfolders-from-txt/23803.htmlhttp://www.computing.net/answers/programming/script-to-maintain-files-in-folders/16780.htmlhttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp8/13/2019 Copy Files Modified In Last Hour Batch.pdf
4/8
collection of scripts. What I would do, is to write 1 script, that can do the following :
Copy 1 file to another folder, only if the file is less than one hour old. It'll be somethinglike:
xcopytime.cmd C:\source\test.jpg C:\target 60
Which would copy file C:\source\test.jpg to C:\target but only if the file is "less than 60minutes old". To check on the "age" of a file, I'll need to call other script, which are
custom.
Let me know if you want this.
Reply Report
#6
Score
0
dngoodMarch 2, 2010 at 06:01:22 Pacific
That sounds great to me; there's no problem running multiple scripts as long as it's fairly
easy to implement!
Dave.
Reply Report
#7
Score
0
Razor2.3March 2, 2010 at 06:15:57 Pacific
dngood:copy image files created in the last hour
What's the scope of this? All image files created anywhere on your PC? All image files
created in a specific directory? All image files created in a specific branch of a directorytree?
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/234507http://www.computing.net/userinfo/234507http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/15853http://www.computing.net/userinfo/15853http://www.computing.net/userinfo/15853http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/234507http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp8/13/2019 Copy Files Modified In Last Hour Batch.pdf
5/8
nbrane:if 'someone' would set something up like a faq or "how-to" page
I ain't stoppin' ya.
Reply Report
#8
Score
0
dngoodMarch 2, 2010 at 06:34:36 Pacific
The files are in all in one directory, there may be different file formats in the directory, iwish to target only the image (jpg) files.
Reply Report
#9
Score
0
nbraneMarch 2, 2010 at 11:52:38 Pacific
@echo off
:: time increment - note: uses environment table var. "nextime" to pass the value
:: increment the current TOD by the input cycle-specification (mmm or hh:mm)
call :norm %1set addm=%mm%
set addh=%hh%
:echo current TOD: %time%
:echo add-cycle, hours: %hh% minutes: %mm%call :norm %time%
set /a hh+=addh
set /a mm+=addmcall :nn
set hh=0%hh%
set mm=0%mm%set nextime=%hh:~-2%:%mm:~-2%
:echo TOD plus add-cycle: %nextime%
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/234507http://www.computing.net/userinfo/234507http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/215180http://www.computing.net/userinfo/215180http://www.computing.net/userinfo/215180http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/234507http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp8/13/2019 Copy Files Modified In Last Hour Batch.pdf
6/8
:at %nextime% %2
set hh=
set mm=
set addh=set addm=
echo.%nextime%goto :eof
:norm
:: normalize input cycle (may be any number of minutes, or hh:mm format):: GIGO alert! --- validation NOT performed! --- GIGO alert!
for /f "tokens=1-2 delims=:" %%x in ("%1") do (
set hh=%%x
set mm=%%y)
if "%mm%" equ "" (
set mm=%hh%set /a hh=0
) else (
if "%hh:~0,1%" equ "0" if "%hh:~1%" neq "" set hh=%hh:~1%)
if "%mm:~0,1%" equ "0" if "%mm:~1%" neq "" set mm=%mm:~1%
:nn
set /a hh+=mm/60set /a mm="mm%%60"
set /a hh="hh%%24"
Reply Report
#10
Score
1
Razor2.3March 3, 2010 at 06:51:18 Pacific
VBScript copies files modified up to an hour ago:Const srcDir = "c:\images"Const destDir = "c:\SomeWittyName"hourAgo = DateAdd("h", -1, Now)Set fso = CreateObject("Scripting.FileSystemObject")
For Each f In fso.GetFolder(srcDir).FilesIf LCase(fso.GetExtensionName(f)) = "jpg" _And f.DateLastModified > hourAgo Then _f.Copy destDir & "\"
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/15853http://www.computing.net/userinfo/15853http://www.computing.net/userinfo/15853http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp8/13/2019 Copy Files Modified In Last Hour Batch.pdf
7/8
8/13/2019 Copy Files Modified In Last Hour Batch.pdf
8/8
minutes =43.933333
hours =0.732222
in days =0.030509
in months =0.001002in years =0.000084
D:\Temp>
Reply Report
#13
Score
1
tvcMarch 10, 2010 at 07:01:33 Pacific
If you are still interested, got a script to copy files, under condition that the file is less than
X minutes old. Scripts are not nicely tuned, but they work. If you need 'em, PM me with
your email adress.
D:\Temp>recentfilecopy test.txt c:\ 2 /Y
File test.txt is 15 minutes old.
File test.txt is older than 2 minutes.
NO copy action is performed now.
D:\Temp>recentfilecopy test.txt c:\ 19 /Y
File test.txt is 15 minutes old.File test.txt is less than 19 minutes old.
xcopy test.txt c:\ /Y
D:test.txt
1 File(s) copied
D:\Temp>
http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfphttp://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/userinfo/137440http://www.computing.net/answers/programming/copy-files-modified-in-last-hour-batch/20948.html#postfp