Hi

I am new to scripting and was wondering if anyone could help me with moving
some files based on there data of creation.

What I am after is the following:

Move all file in d:\folder1\*.* between 01/01/05 - 31/01/05 to
d:\folder2\012005.

I have figured how to move files by the following:

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "D:\Script_test\Folder1\*.*" , "D:\Script_test\Folder2\"

But dont know how todo the data thing.

Any help would be great.

Thanks

James

RE: New to scripting - Help creat a scrip to move files based on date? by ESP

ESP
Mon Nov 07 11:22:09 CST 2005

**** Here's the code to get your Creation Dates:

'---begin code---
Set objLogParser = CreateObject("MSUtil.LogQuery")
Set objInputFormat = CreateObject("MSUtil.LogQuery.FileSystemInputFormat")
objInputFormat.Recurse = 0
Set objOutputFormat = CreateObject("MSUtil.LogQuery.NativeOutputFormat")
objOutputFormat.rtp = -1
strQuery = "SELECT Name, CreationTime FROM 'd:\folder1\*.*' " & _
"WHERE NOT Attributes LIKE '%D%' ORDER BY CreationTime"
objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat
'---end code---

**** Here's the code to determine if that date falls in-between a certain
timeline:

'---begin code---
dtmStartDate = #7/1/2005#
dtmEndDate = #7/31/2005#
dtmTargetDate = #12/25/2005#
If dtmTargetDate >= dtmStartDate AND dtmTargetDate <= dtmEndDate Then
Wscript.Echo "The target date is within the specified range."
Else
Wscript.Echo "The target date is not within the specified range."
End If
'---end code---


ESP




"James Brown" wrote:

> Hi
>
> I am new to scripting and was wondering if anyone could help me with moving
> some files based on there data of creation.
>
> What I am after is the following:
>
> Move all file in d:\folder1\*.* between 01/01/05 - 31/01/05 to
> d:\folder2\012005.
>
> I have figured how to move files by the following:
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.MoveFile "D:\Script_test\Folder1\*.*" , "D:\Script_test\Folder2\"
>
> But dont know how todo the data thing.
>
> Any help would be great.
>
> Thanks
>
> James
>
>
>

Re: New to scripting - Help creat a scrip to move files based on date? by Fosco

Fosco
Mon Nov 07 22:06:17 CST 2005

"James Brown"

'generic sample :

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\doc")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 30 Then
fso.MoveFile f1 , "c:\Windows\Temp\"
End If
Next

http://www.google.it/search?hl=it&q=DateDiff%2Bvbs&meta=
--
Fosco




Re: New to scripting - Help creat a scrip to move files based on date? by James

James
Tue Nov 08 04:50:47 CST 2005

Thanks Fosco,

How can I change that just todo the months.

So move everthing thing for Nov, Dec, Jan, etc.....

J


"Fosco" <fake@fake.invalid> wrote in message
news:4370243a$0$41150$14726298@news.sunsite.dk...
> "James Brown"
>
> 'generic sample :
>
> Dim fso, f, f1, fc
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.GetFolder("C:\doc")
> Set fc = f.Files
> For Each f1 in fc
> If DateDiff("d", f1.DateLastModified, Now) > 30 Then
> fso.MoveFile f1 , "c:\Windows\Temp\"
> End If
> Next
>
> http://www.google.it/search?hl=it&q=DateDiff%2Bvbs&meta=
> --
> Fosco
>
>
>



Re: New to scripting - Help creat a scrip to move files based on date? by Dr

Dr
Tue Nov 08 10:49:20 CST 2005

JRS: In article <6293DE8F-BA20-4649-A895-35116BC466F3@microsoft.com>,
dated Mon, 7 Nov 2005 09:22:09, seen in news:microsoft.public.scripting.
vbscript, ESP <ESP@discussions.microsoft.com> posted :

>dtmStartDate = #7/1/2005#

And what do you expect the OP's system will interpret that as, given
that he is explicitly and manifestly UK?

In an international medium such as this, VBS date literals should be
given as #2005/12/25#.



James : if you can use a DOS box (a.k.a. MS-DOS prompt), my HUNT, via
sig line 3, will do what you want :

HUNT d:\folder1\*.* f2005-01-01 b2005-02-01 "move" "d:\folder2\012005"

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)

Re: New to scripting - Help creat a scrip to move files based on date? by Fosco