Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Last modified file
Name: Mustang11 Date: May 25, 2009 at 22:02:18 Pacific OS: Windows XP Subcategory: General
Comment:
Hi I want to copy all files that were modified in the last 12 or 24 hours from one directory to another. Can anyone help me? It must also only be .app files Please someone help.
Name: Mustang11 Date: May 26, 2009 at 01:25:56 Pacific
Reply:
Sorry I should of been more specific I mean in a batch file that I want to run at night
0
Response Number 3
Name: Mechanix2Go Date: May 26, 2009 at 02:20:32 Pacific
Reply:
If you cruise the programming section, you'll see that 'date math' is never a happy subject for batch script.
I can show how to copy files modified TODAY. Is that any help?
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 4
Name: Mustang11 Date: May 26, 2009 at 02:35:56 Pacific
Reply:
Yes that would be great, all I want is to copy files that were modified on the day.
0
Response Number 5
Name: Mechanix2Go Date: May 26, 2009 at 04:13:04 Pacific
Reply:
I'll get back to you.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 6
Name: Mustang11 Date: May 26, 2009 at 04:26:15 Pacific
Reply:
Ok thank you.
0
Response Number 7
Name: Mechanix2Go Date: May 28, 2009 at 09:45:12 Pacific
Reply:
@echo off > %TEMP%\#-# setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in ('dir/b/s %TEMP%\#-#') do ( set mydate=%%~Ta )
for /f "tokens=1 delims= " %%a in ("!mydate!") do ( set today=%%a )
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do ( set TD=%%~Ta for /f "tokens=1 delims= " %%a in ("!TD!") do ( set filedate=%%a ) if !filedate! equ !today! echo process %%a )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 8
Name: Mustang11 Date: May 28, 2009 at 21:31:42 Pacific
Reply:
Thanx Man, Then after that do I just copy the files over?
0
Response Number 9
Name: ghostdog Date: May 28, 2009 at 21:47:43 Pacific
Reply:
forget about batch when it comes to date maths. use vbscript
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
If DateDiff("h",strFile.DateLastModified,Now) < 24 Then
strFileName = strFile.Name
objFS.CopyFile strFolder&"\"&strFileName,"c:\tmp"
End If
Next
on command prompt
c:\test> cscript /nologo myscript.vbs
0
Response Number 10
Name: Mustang11 Date: May 28, 2009 at 21:54:41 Pacific
Reply:
Thank you for your help?
What changes to make it applicable for my folders?
0
Response Number 11
Name: Mechanix2Go Date: May 29, 2009 at 02:00:54 Pacific
Reply:
To copy the files which are dated today, edit the last line, replacing:
echo process %%a
with:
copy %%a d:\some\folder
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 12
Name: Mustang11 Date: May 29, 2009 at 02:24:56 Pacific
Reply:
OK Thanx alot man
0
Response Number 13
Name: Mustang11 Date: May 29, 2009 at 03:50:50 Pacific
Reply:
Can I know another thing please?
Is it possible to only copy a certain type of file?
0
Response Number 14
Name: Mechanix2Go Date: May 29, 2009 at 05:34:40 Pacific
Reply:
On line 15 change to, for instance, dir/b/a-d *.mp3 to do the mp3 files.
Don't use this script. The line numbers are just to show what's what.
[1]:: lesson learned: /s is needed w %TEMP% [2]:: process only today's files [3] [4]@echo off > %TEMP%\#-# [5]setLocal EnableDelayedExpansion [6] [7]for /f "tokens=* delims= " %%a in ('dir/b/s %TEMP%\#-#') do ( [8]set mydate=%%~Ta [9]) [10] [11]for /f "tokens=1 delims= " %%a in ("!mydate!") do ( [12]set today=%%a [13]) [14] [15]for /f "tokens=* delims= " %%a in ('dir/b/a-d') do ( [16]set TD=%%~Ta [17]for /f "tokens=1 delims= " %%a in ("!TD!") do ( [18]set filedate=%%a [19]) [20]if !filedate! equ !today! echo process %%a [21])
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 15
Name: Mustang11 Date: May 29, 2009 at 05:46:33 Pacific
Summary: I need help with the following problem: Using MS cabarc.exe, I create an archive containing several files. Some of those files were last modified over a year ago, and others were last modified only a ...
Summary: filezilla maybe others should provide you with the file permissions. If you do have read write on that account then you should be able to modify files or at least see the permissions. I can only gues...
Summary: when i try to restart Firefox to install an update, i get this error message: "one or more files could not be updated. please make sure all other applications are closed and that you have permission ...