Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to get teh recentest created file in a folder

Reply
 
Old 05-04-2009   #1 (permalink)
Joshwa


 
 

How to get teh recentest created file in a folder

How can get a latest or oldest created file in folder with VBscript? Is there
a method to do this task?

--
Enjoy today

My System SpecsSystem Spec
Old 05-04-2009   #2 (permalink)
Todd Vargo


 
 

Re: How to get teh recentest created file in a folder

Joshwa wrote:
Quote:

> How can get a latest or oldest created file in folder with VBscript? Is
there
Quote:

> a method to do this task?
Sorry, I don't understand the task. Your subject line says "recentest"
meaning the newest. In the body of the message you say "latest or oldest"
which means the opposite. Which is it?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 05-04-2009   #3 (permalink)
Al Dunbar


 
 

Re: How to get teh recentest created file in a folder


"Todd Vargo" <tlvargo@xxxxxx> wrote in message
news:O7kTk0RzJHA.1388@xxxxxx
Quote:

> Joshwa wrote:
Quote:

>> How can get a latest or oldest created file in folder with VBscript? Is
> there
Quote:

>> a method to do this task?
>
> Sorry, I don't understand the task. Your subject line says "recentest"
> meaning the newest. In the body of the message you say "latest or oldest"
> which means the opposite. Which is it?
In either case, I would process the collection of contained files, keeping
track of which is the oldest or newest according to its created date.

/Al


My System SpecsSystem Spec
Old 05-05-2009   #4 (permalink)
Joshwa


 
 

Re: How to get teh recentest created file in a folder

Todd,
Sorry to confusing you.
I did mean either the newest or oldest created file in a folder like Al
mentioned
In SQL Server I can use Max or Min to get the newest or oldest file in a
table after I put list of files in a folder into the table.
But I don't know if there is similar methods in VBScript.

--
Enjoy today


"Al Dunbar" wrote:
Quote:

>
> "Todd Vargo" <tlvargo@xxxxxx> wrote in message
> news:O7kTk0RzJHA.1388@xxxxxx
Quote:

> > Joshwa wrote:
Quote:

> >> How can get a latest or oldest created file in folder with VBscript? Is
> > there
Quote:

> >> a method to do this task?
> >
> > Sorry, I don't understand the task. Your subject line says "recentest"
> > meaning the newest. In the body of the message you say "latest or oldest"
> > which means the opposite. Which is it?
>
> In either case, I would process the collection of contained files, keeping
> track of which is the oldest or newest according to its created date.
>
> /Al
>
>
>
My System SpecsSystem Spec
Old 05-05-2009   #5 (permalink)
Al Dunbar


 
 

Re: How to get teh recentest created file in a folder


"Joshwa" <Joshwa@xxxxxx> wrote in message
news:2F9E75E8-1AE6-4A53-9E6A-0729C571A351@xxxxxx
Quote:

> Todd,
> Sorry to confusing you.
> I did mean either the newest or oldest created file in a folder like Al
> mentioned
> In SQL Server I can use Max or Min to get the newest or oldest file in a
> table after I put list of files in a folder into the table.
> But I don't know if there is similar methods in VBScript.
VBScript has no no max function and no min function, however, whether you
use vbscript, SQL server, or powershell, it is not just a matter of min/max,
but of extracting the name and creation date of the files in a folder, and
then storing them in some structure.

The simple, straightforward, vbscript approach would be to process the file
collection in a loop as I said below; here is a pseudocode (i.e. some
details missing) start:

oldfile = ""
newfile = ""
oldcre = <today>
newcre = <100 years ago>
for each file in the folder object
name = get the filename
cre = get the file's creation date
if ( cre < oldcre ) then
oldfile = name
oldcre = cre
elseif ( cre > newcre ) then
newfile = name
newcre = cre
end if
next

A more SQL-like solution could make use of ADO queries, however, I do not
know if there is an ADO interface to the file system. If there were it could
work directly, otherwise, you would have to use a for each loop to extract
the file names and creation dates into some format against which an ADO
query could be targetted. IMHO that would make more sense if there were
other database-style operations you might want to perform. Otherwise the
straightforward approach may be the simplest.

/Al
Quote:

> --
> Enjoy today
>
>
> "Al Dunbar" wrote:
>
Quote:

>>
>> "Todd Vargo" <tlvargo@xxxxxx> wrote in message
>> news:O7kTk0RzJHA.1388@xxxxxx
Quote:

>> > Joshwa wrote:
>> >> How can get a latest or oldest created file in folder with VBscript?
>> >> Is
>> > there
>> >> a method to do this task?
>> >
>> > Sorry, I don't understand the task. Your subject line says "recentest"
>> > meaning the newest. In the body of the message you say "latest or
>> > oldest"
>> > which means the opposite. Which is it?
>>
>> In either case, I would process the collection of contained files,
>> keeping
>> track of which is the oldest or newest according to its created date.
>>
>> /Al
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file VB Script
RE: The folder could not be created." Vista mail
the folder cannot be created Vista mail
Can't modify a folder I created myself Vista file management
Can't open folder I created in XP Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46