Solved

Batch file to list all files in a folder

Posted on 2007-11-15
3
9,526 Views
Last Modified: 2008-02-01
Experts,
I'm trying to write a batch file that will scan through a folder and pick a certain file. The file that i'm looking for is the file that was put into the folder first. As files get dropped into the folder they get named as
as001.abc
as002.abc
as003.abc
as004.abc

What I want to do is to pick the file with the highest (or lowest) number and copy it to another folder.

As a test i tried the code below but it did not work.

rem @echo off
IF EXIST d:\mydir\*.* goto process
echo does not exist
:process
for each %%a in (d:\mydir\*.*) do echo %%a
pause


Please assist.

Thanks.
0
Comment
Question by:mamba100
3 Comments
 
LVL 13

Accepted Solution

by:
rhinoceros earned 50 total points
Comment Utility
Change to -->

rem @echo off
IF EXIST d:\mydir\*.* goto process
echo does not exist
goto exit
:process
for %%a in (d:\mydir\*.*) do echo %%a
:exit
pause
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
EE Admin
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now