Solved

Batch file to list all files in a folder

Posted on 2007-11-15
3
9,531 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL to download Windows 10 Enterprise 64-bit .ISO 4 273
For loop to add numbers 3 72
Date variable in batch file 2 26
Autosar OS Multicore Share Resources confusion ? 2 34
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
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.

815 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

8 Experts available now in Live!

Get 1:1 Help Now