1
votes

I am trying to code a script to automatically process some of our daily ftp files. I have already coded the files to download from the source ftp using WinSCP and calling it in a .bat file, and would ideally like to call it within the same bat. Scripting Language does not matter, as long as I can run/call it from the original batch.

I need will extract the date from a filename, and unzip the contents into corresponding folders. The source file is delivered automatically daily via FTP, and the filename is:

SOFL_CLAIM_TC201702270720000075.zip

The bolded section is the date that I would like to extract. The contents of the .zip include two types of content, multiple PDFs and a .dat file.

For the supplied date of 20170227, the pdfs need to get extracted to a folder following the format:

\%root%\FNOIs\2017\02-Feb\02-27-2017

At the same time, the .dat file needs to get extracted to multiple folders following the format:

\%root%\Claim Add\2017 Claim Add\02-2017
\%root2%\vendorFTP\VendorFolder

After extracting, I need to move the source zip to

\%root%\Claim Add\2017 Claim Add\02-2017

What is the best way off accomplishing all of this?

I am assuming it would be the for /f batch command, but I am new to batch coding and cannot figure out how to start it from scratch.

I also have 7zip installed, but do not understand how to use the command-line options.

1

1 Answers

0
votes

You have asked for a lot in one question, and not shown any code or demonstrated effort on your part.

For the first part, once you have the filename in a variable:

set FILENAME=SOFL_CLAIM_TC201702270720000075.zip

You can get the date part with:

echo %FILENAME:~13,-14%

The syntax: :13,-14 means "Remove the first 13 letters and the last 14 letters." That should leave you with just the date.

When you integrate that into your script, Show Your Code