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 there any similar command or script in DOS?
@echo off & setLocal EnableDelayedExpansion
cd D:\apps\Infa\param\
if exist "%1".prm del /F "%1".prm
for /f "tokens=* delims= " %%a in ('dir/b/a-d/o/n D:\apps\Infa\param\"%1_"*.prm') do (
ren %%a "%1".prm
goto :eof
)