Last modified file

May 25, 2009 at 22:02:18
Specs: Windows XP
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.

See More: Last modified file

Report •


#1
May 26, 2009 at 01:16:20
... there is one in xp go to start search click "all files and folders" click > "when was it modified?" > specify dates

Grrrr
"...pentathol makes you sing like a canary"
http://img193.imageshack.us/img193/...
... got brain freeze


Report •

#2
May 26, 2009 at 01:25:56
Sorry I should of been more specific
I mean in a batch file that I want to run at night

Report •

#3
May 26, 2009 at 02:20:32
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


Report •

Related Solutions

#4
May 26, 2009 at 02:35:56
Yes that would be great, all I want is to copy files that were modified on the day.

Report •

#5
May 26, 2009 at 04:13:04
I'll get back to you.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#6
May 26, 2009 at 04:26:15
Ok thank you.

Report •

#7
May 28, 2009 at 09:45:12
@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


Report •

#8
May 28, 2009 at 21:31:42
Thanx Man, Then after that do I just copy the files over?

Report •

#9
May 28, 2009 at 21:47:43
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


Report •

#10
May 28, 2009 at 21:54:41
Thank you for your help?

What changes to make it applicable for my folders?


Report •

#11
May 29, 2009 at 02:00:54
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


Report •

#12
May 29, 2009 at 02:24:56
OK Thanx alot man

Report •

#13
May 29, 2009 at 03:50:50
Can I know another thing please?

Is it possible to only copy a certain type of file?


Report •

#14
May 29, 2009 at 05:34:40
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


Report •

#15
May 29, 2009 at 05:46:33
Thanx man that is a huge help thanx

Report •


Ask Question