![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script to grab lines between two values | JamesByars | Shell Programming and Scripting | 3 | 09-19-2008 12:07 AM |
| Script to rename files | Dinkster | UNIX for Dummies Questions & Answers | 5 | 01-22-2008 08:55 AM |
| please help - script to list and rename | happyv | Shell Programming and Scripting | 2 | 10-04-2006 03:50 AM |
| search and grab data from a huge file | ting123 | UNIX for Dummies Questions & Answers | 1 | 06-06-2006 09:41 PM |
| How to Grab the latest file | n9ninchd | UNIX for Dummies Questions & Answers | 1 | 05-10-2001 04:31 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
![]() 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? Thanks for your help, ![]() |
|
||||
|
Hi Raghav,
DOS as well has a single command which does teh same job... see below e.g. C:\Documents and Settings\ilango>echo . > abc1092.txt C:\Documents and Settings\ilango>echo . > abc1022.txt C:\Documents and Settings\ilango>echo . > abc1023.txt C:\Documents and Settings\ilango>echo . > abc1024.txt C:\Documents and Settings\ilango>for /F %i in ('dir /B abc*') do move /Y %i abc .txt C:\Documents and Settings\ilango>move /Y abc1022.txt abc.txt C:\Documents and Settings\ilango>move /Y abc1023.txt abc.txt C:\Documents and Settings\ilango>move /Y abc1024.txt abc.txt C:\Documents and Settings\ilango>move /Y abc1092.txt abc.txt C:\Documents and Settings\ilango> /ilan Last edited by ilan; 04-06-2009 at 03:48 PM.. Reason: cleanup in teh e.g. |
|
||||
|
Thanks for the reply! i got the solution...
![]() @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 ) |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|