Solved

Batch file to list all files in a folder

Posted on 2007-11-15
3
9,529 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
ID: 20296670
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
ID: 20649596
Forced accept.

Computer101
EE Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

22 Experts available now in Live!

Get 1:1 Help Now