Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,887 of 42,547    |
|    Herbert Kleebauer to ehabaziz2001@gmail.com    |
|    Re: processing same files with same pref    |
|    14 Jan 14 13:17:35    |
   
   From: klee@unibwm.de   
      
   On 14.01.2014 12:33, ehabaziz2001@gmail.com wrote:   
   > I have a directory that containing files that may or may not contain the   
   same prefix like this :   
   >   
   > xxx_part1.txt   
   > xxx_part2.txt   
   > yyy_part1.txt   
   > yyy_part2.txt   
   > zzz_part1.txt   
   > zzz_part2.txt   
   > aaa_part1.txt   
   > bbb_part1.txt   
   >   
   > I need to run a concatenate file commands per each paris like this:   
   > copy /b xxx_conc.txt+xxx_part1.txt+xxx_part2.txt   
   > copy /b yyy_conc.txt+yyy_part1.txt+yyy_part2.txt   
   >   
   >   
   > How can I perform this task using for loop. The separator per each prefix is   
   the underscore.   
   >   
   > for /F "tokens=*" %%* in ('dir /b *.RPT') do (   
      
   Assuming that ending is .txt and not .rpt and there are no more than   
   five parts:   
      
      
   for /f %%i in ('dir /b *part1.txt') do call :sub %%i   
   goto :eof   
      
   :sub   
   set n=%~n1   
   set n=%n:~0,-6%   
   copy /b %n%_part1.txt+%n%_part2.txt+%n%_part3.txt+%n%_part4.txt+%n%_part5.txt   
   %n%_conc.txt   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca