1- Ignore all headersHow are "headers" identified, is it always just the first line of every file, or is there some other pattern?
2- include only files created in specific date rangePlease give some examples of what this selection would be. DO you just want a from and a to date, or a certain number of days, etc?
3- include only files with specific names, like "*PatSched* and "*PatChanges*"All files will be in the same base folder? And only files matching one or more normal file patterns will be selected?
How are "headers" identified, is it always just the first line of every file, or is there some other pattern?Always the 1st line.
Please give some examples of what this selection would be. DO you just want a from and a to date, or a certain number of days, etc?Would start with files created in the last 24 hours, with option to modify..
All files will be in the same base folder? And only files matching one or more normal file patterns will be selected?Yes.
Is BAT acceptable?Yes.
@echo off
setlocal EnableDelayedExpansion
rem Set path to folder where files to process exist
set BaseDir=H:\FTP
rem Set name for merged output file
set OutputFile=merged.txt
rem Get path to folder where this BAT script exists
set ScriptPath=%~dp0
rem Delete output file if it exists
if exist "%BaseDir%\%OutputFile%" del "%BaseDir%\%OutputFile%"
rem Process all matching files in base folder, sorting by create date/time
for /f "tokens=*" %%F in ('dir /b /a-d /od /tc "%BaseDir%\*SchChanges*"') do (
rem For each file, call VBS script to calculate created age in hours from now
set Fileage=
for /f "tokens=*" %%A in ('cscript //nologo "%ScriptPath%\EE29116756.vbs" "%BaseDir%\%%~F"') do (
set Fileage=%%A
)
rem If we got it's age, see if it meets criteria, if so append to output file skipping first line
if defined FileAge (
if !FileAge! LEQ 24 (
more +1 "%BaseDir%\%%~F" >> "%BaseDir%\%OutputFile%"
)
)
)
Saved both under same folder as those files exists (see attached), but nothing gets created. for /f "tokens=*" %%A in ('cscript //nologo "%ScriptPath%\EE29116756.vbs" "%BaseDir%\%%~F"') do (
for /R %F in (*.csv) do type "%F" >> output.csv
Thanks,for /R %F in (*.csv) do (if /i "%F" NEQ "%CD%\output.csv" (type "%F">> output.csv))
Open in new window