Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch file to list all files in a folder

Posted on 2007-11-15
3
Medium Priority
?
9,554 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 200 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

Industry Leaders: 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

Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
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.

609 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