get only last file of same type
Posted: 27 Apr 2018 04:08
Hello everybody,
a new problem at least difficult for me
In a directory I have different file, I must add each one for same name at 3th position in a new file one and delete it after copy.
This is a script and it works fine
The problem is when I have more file with same name at 1th position, in this case I want copy only last file arrived and delete others same with 1st name
Example list file:
AAAAAAAA.BBBBBBBB.CCCCCCCC.03024
EEEEEEEE.BBBBBBBB.CCCCCCCC.02052
FFFFFFFF.BBBBBBBB.DDDDDDDD.00155
EEEEEEEE.BBBBBBBB.DDDDDDDD.13099
EEEEEEEE.BBBBBBBB.DDDDDDDD.13100
EEEEEEEE.BBBBBBBB.DDDDDDDD.13101
EEEEEEEE.BBBBBBBB.DDDDDDDD.13102
Example output file in %OUTPUT% folder, must contain only this FFFFFFFF.BBBBBBBB.DDDDDDDD.00155 and this file EEEEEEEE.BBBBBBBB.DDDDDDDD.13102 put in this file DDDDDDDD with type command
If I add to dir command I can select last file but of all file, not only same 1st type of file
Suggestion?
Thank you in advance
a new problem at least difficult for me
In a directory I have different file, I must add each one for same name at 3th position in a new file one and delete it after copy.
This is a script and it works fine
Code: Select all
for /F %%a in ('dir %folder%\*.DDDDDDDD.* /b/a-d/od') do type "%folder%\%%a" >> %OUTPUT%\DDDDDDDD && del /Q %folder%\%%a
Example list file:
AAAAAAAA.BBBBBBBB.CCCCCCCC.03024
EEEEEEEE.BBBBBBBB.CCCCCCCC.02052
FFFFFFFF.BBBBBBBB.DDDDDDDD.00155
EEEEEEEE.BBBBBBBB.DDDDDDDD.13099
EEEEEEEE.BBBBBBBB.DDDDDDDD.13100
EEEEEEEE.BBBBBBBB.DDDDDDDD.13101
EEEEEEEE.BBBBBBBB.DDDDDDDD.13102
Example output file in %OUTPUT% folder, must contain only this FFFFFFFF.BBBBBBBB.DDDDDDDD.00155 and this file EEEEEEEE.BBBBBBBB.DDDDDDDD.13102 put in this file DDDDDDDD with type command
If I add
Code: Select all
t:c
Suggestion?
Thank you in advance