Hi,
I have 50 text files in one directory, (C:\combined). I want merge them to a single file but with one condition that to verify each file date and which is mentioned on line 2 DATE : dd/mm/yyyy. Merge all the file of Today's date only to new file c:\Real\Report.txt, and to move all those merged file to c:\backups
File format
line 1......
line 2.......................DATE : dd/mm/yyyy(aligned centre).........................User : xyz
data...
data...
data...
The structure of all the files are same and does not change.
Thanks in advance.
Concatenate multiple files
Moderator: DosItHelp
Re: Concatenate multiple files
Some options:
Robocopy with /MAXAGE:1
Robocopy with /MAXAGE:1
Code: Select all
SET INPUT=C:\TEST
SET TEMP=C:\TEMP
SET OUTPUT=C:\Results
IF EXIST %OUTPUT%\Results.txt DEL %OUTPUT%\Results.txt
CD %INPUT%
FOR %%F IN ( *.txt ) DO (
ROBOCOPY %INPUT% %TEMP% /MOVE /Maxage:1
TYPE %TEMP%\%%F >> %OUTPUT%\Results.txt
RMDIR /s /q %TEMP%
)
Code: Select all
SET INPUT=C:\combine
SET TEMP=C:\TEMP
SET OUTPUT=C:\Results
ROBOCOPY %INPUT% %TEMP% /MOVE /Maxage:1
IF NOT EXIST %OUTPUT% MKDIR %OUTPUT%
TYPE %TEMP%\*.txt >> %OUTPUT%\Results.txt
RMDIR /s /q %TEMP%