Search : in
By :

DOS script to grab first file on directory

raghav525, on Mar 17, 2009 5:41:47 pm GMT 
 Report this message to moderators

Hello,
Is there any way to use the dir command / some DOS Script to select only first file of similar pattern of files in a direcotory and rename it
for example, one directory has 5 files
abc_1005.txt
abc_5256.txt
abc_2001.txt
abc_2003.txt
abc_3006.txt
by use script i would like to select only first file abc_1005.txt and rename(move) it as abc.txt;
For next run, directory has 4 files, script returns the first file as abc_5256.txt and rename it as abc.txt...

In unix, the we can use a single line command as
mv `ls /u01/opt/incoming/abc_*.txt | head -1 ` abc.txt

i just wondering is ther any similar command or script in DOS?

Thanks for your help,

Configuration: Windows XP
Internet Explorer 6.0

Best answers for « DOS script to grab first file on directory » in :
[MS-Dos]List the contents of a directory in a file Show[MS-Dos]List the contents of a directory in a file Intro Explanation Intro It may be convenient to make the listing of one or more directories in a file, to make a catalog of files. Under MS-DOS (or Windows by opening a...
Basic MS-Dos commands ShowBasic MS-Dos commands Intro The command prompts: Intro Here is a list of basic commands that you can use in a DOS prompt (e.g. a using a boot disk). To have additional information about these commands, type /? after entering the...
Inserting text in a file ShowInserting text in a file Introduction Syntax Introduction It is sometimes useful to insert text in the header of one or more document (s) or in a specific part of the document (before or after a specific line). The publisher of...
Download NTFS Reader ShowIt is now possible to have access to NTFS readers from MS DOS. NTFS Reader DOS Disk Boot allows the reading of NTFS readers from MS DOS. It supports long file names as well as well as compressed or fragmented files. NTFS Reader DOS Disk Boot...
Operating Systems - MS-DOS - Tips ShowSetting the CD-ROM drive The CD-ROM drive is configured in the config.sys and autoexec.bat system files. The CD-ROM drive device driver must be configured in the config.sys file (even if the device is automatically detected in Windows). To do...
FAT16 and FAT32 ShowThe FAT16 file system The first file system to be used on a Microsoft operating system was the FAT system, which uses a file allocation table. The file allocation table is actually an index which lists the content of the disk in order to record the...