Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to loop over all files in a directory sorted by name or last modified date?

1,639 views
Skip to first unread message

Dennis Halver

unread,
Mar 31, 2010, 4:23:55 AM3/31/10
to
Ok, I know how to loop non-recursively in a DOS batch file over all
files matching a pattern in a certain directory:

for %%a in ("%path_to_log%\*.log") do (
echo investigating logfile=%%a)

But in which sequence are the files processed?
Are the files ordered by fiename or by last modified date or arbitrarily?

How can I force the processing in
- filename
- last modified timestamp

sort order in a DOS batch file under WinXP?

Dennis

Todd Vargo

unread,
Mar 31, 2010, 6:41:48 PM3/31/10
to

Silent redirection detected before posting = Rest of msg deleted.

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

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Zaphod Beeblebrox

unread,
Apr 5, 2010, 8:13:34 AM4/5/10
to

<ten.n...@virgin.net> wrote in message
news:rj70e1u712pl.1glniocm2oaqt$.dlg@40tude.net...
> On Sun, 04 Apr 2010 11:59:44 +0000, charles wrote:
>
>> On 31 Mar 2010 08:23:55 GMT, ha...@persrec.com (Dennis Halver)
>> for /f %a in ('dir /b /od *.log') do @something "%a"
>
> I must say that its really heartening to know that more than four
> days
> after having provided a response, that someone would provide an
> almost,
> (but not quite as full), similar response! Thank you charles for
> showing
> your support for my solution.


There's a very good chance that charles didn't see your response. If
you look carefully, the OP - Dennis Halver - posted to
alt.msdos.batch, comp.os.msdos.misc, and alt.msdos.batch.nt, but set
followups to alt.msdos.batch.nt without noting it in his post. (He
does this a lot, and ignores repeated requests to change this
practice).

So, if charles saw the original post in alt.msdos.batch or
comp.os.msdos.misc, your reply would not have been present and charles
would have thought it helpful to reply as he did. He is quite
possibly wondering where his post went even now - yet another reason
why Dennis Halver should change his habit of silently setting
followups...

--
Zaphod

Voted "Worst Dressed Sentient Being in the Known Universe" for seven
years in a row.


0 new messages