Solved

Batch file to list all files in a folder

Posted on 2007-11-15
3
9,541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
move command 5 68
how to pick file up from ftp via batch file 2 81
WORM compliant device  what is it? 12 112
What does Windows SKU stand for? 7 35
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

738 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