Adding manifest list for weekly FTP files
Moderator: DosItHelp
Adding manifest list for weekly FTP files
Good afternoon. I have an FTP task set up that transmits a number of files to a vendor but the Service Delivery team is requesting that I create a manifest file to send along with the data files. Is it possible to scan a file for the number or rows and output the results to a file? What I'm picturing in a single manifest file like weekly_ftp.mft that would contain something like
filename1 900000 rows 153000 Kb
filename2 90000 rows 96000 Kb
filename3 1000 rows 10000 Kb
Any guidance would be greatly appreciated.
Frank
filename1 900000 rows 153000 Kb
filename2 90000 rows 96000 Kb
filename3 1000 rows 10000 Kb
Any guidance would be greatly appreciated.
Frank
Re: Script Help Request
I assume these are text files.
Are they fixed length text files or are they delimited?
Are they fixed length text files or are they delimited?
Re: Script Help Request
That is correct. They are | pipe delimited text files with .dat as the extension. Sample data from one of the files looks like this:
20|000042|D|000
20|000082|Y|100
20|000103|D|000
20|000120|M|000
20|000123|M|000
20|000124|M|000
20|000205|Y|100
20|000225|D|000
20|000317|M|000
20|000473|D|000
20|000501|M|100
20|000510|D|000
20|000519|D|000
20|000543|D|000
But they all have different numbers of columns. Each line is ended with {CR}{LF}
20|000042|D|000
20|000082|Y|100
20|000103|D|000
20|000120|M|000
20|000123|M|000
20|000124|M|000
20|000205|Y|100
20|000225|D|000
20|000317|M|000
20|000473|D|000
20|000501|M|100
20|000510|D|000
20|000519|D|000
20|000543|D|000
But they all have different numbers of columns. Each line is ended with {CR}{LF}
Re: Script Help Request
Depending on how your FTP script accepts the filenames then it can include a subroutine like this: (untested)
Calll it like this:
Code: Select all
:manifest_list
for %%a in ("%~1") do (
for /f %%b in (' find /c /v "" ^< "%%a" ') do >>"weekly_ftp.mft" echo %%~nxa - %%b - %%~za
)
goto :EOF
Calll it like this:
Code: Select all
call :manifest_list "filename.dat"
Re: Adding manifest list for weekly FTP files
Thanks foxidrive but I'm not sure how to implement this code. Do I save it as a .bat file in the c: drive? Thanks for your help with this.
Code: Select all
:manifest_list
for %%a in ("%~1") do (
for /f %%b in (' find /c /v "" ^< "%%a" ') do >>"weekly_ftp.mft" echo %%~nxa - %%b - %%~za
)
goto :EOF
Re: Adding manifest list for weekly FTP files
You can put into your existing BATCH file like a function.
Re: Adding manifest list for weekly FTP files
Here's another way to use it.
Create a batch file with this and name it manifest_list.bat and place it in the folder with the dat files and FTP batch file or in a folder that is on the path.
Then in your batch file you can use a line like this assuming your file is called filename.dat
call manifest_list.bat "c:\storage\folder\filename.dat"
or like this if they are in the same folder:
call manifest_list.bat "filename.dat"
Create a batch file with this and name it manifest_list.bat and place it in the folder with the dat files and FTP batch file or in a folder that is on the path.
Code: Select all
@echo off
:manifest_list.bat
for %%a in ("%~1") do (
for /f %%b in (' find /c /v "" ^< "%%a" ') do >>"weekly_ftp.mft" echo %%~nxa - %%b - %%~za
)
goto :EOF
Then in your batch file you can use a line like this assuming your file is called filename.dat
call manifest_list.bat "c:\storage\folder\filename.dat"
or like this if they are in the same folder:
call manifest_list.bat "filename.dat"
Re: Adding manifest list for weekly FTP files
Thanks again foxidrive. I created the .bat file as suggested and added the following to the beginning of the FTP .bat file. Thanks again for your help, this was a much quicker solution than I had hoped for!
Frank
Code: Select all
Cd c:\
echo filename - rows - filesize > weekly_ftp.mft
Call manifest_list.bat "e:\transfer\file1.dat"
Call manifest_list.bat "e:\transfer\file2.dat"
Call manifest_list.bat "e:\transfer\file3.dat"
Call manifest_list.bat "e:\transfer\file4.dat"
Frank