Powershell: Match array strings (from 2 txt files) line for line

I am trying to figure out how to join strings from two arrays (line for line).
Overview:
I need to run a third party app against a set of files. The output file generated by the 3rd party app (different file format) needs to be delivered to the same directory as the source file.
EXAMPLE:
I have generated the required files:
$sourceFiles = c:\temp\sFiles.txt
$sourceDirs = c:\temp\sDirs.txt
# each line in both arrays need to be matched one for one
For instance:
sourceFiles.txt would contain:
c:\one\please.log
c:\one\two\help.log
c:\one\two\help2.log
c:\one\three\me.log
sourceFolders.txt would contain:
c:\one
c:\one\two
c:\one\two
c:\one\three
As stated, I need to match the two line for line (up to 10000 lines)...SO

I need to be able to loop through the arrays run the app something like this:
& 'c:\program files\3rdPartyApp\App.exe' $sourceFile $sourceDir
OR
& 'c:\program files\3rdPartyApp\App.exe' c:\one\please.log c:\one\two
.... and so on.

Not sure if this is possible?
LVL 5
daveTechSearchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rlandquistCommented:
Try this.
$sourceFiles  = Get-Content "c:\temp\sFiles.txt"
$sourceDirs = Get-Content "c:\temp\sDirs.txt"

for ($i = 0; $i -lt $sourceFiles .count; $i++)
{
	[Diagnostics.Process]::Start('c:\program files\3rdPartyApp\App.exe', $sourceFiles [$i] $sourceDirs[$i])
}

Open in new window

0
rlandquistCommented:
Sorry, extra space, here it is fixed
$sourceFiles  = Get-Content "c:\temp\sFiles.txt"
$sourceDirs = Get-Content "c:\temp\sDirs.txt"

for ($i = 0; $i -lt $sourceFiles.count; $i++)
{
	[Diagnostics.Process]::Start('c:\program files\3rdPartyApp\App.exe', $sourceFiles [$i] $sourceDirs[$i])
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daveTechSearchAuthor Commented:
should that increment to the next line?... I am seeing it only increment to the next character on the first line
'c', ':', and '\'
 
0
daveTechSearchAuthor Commented:
Got it to work, with a little bit of rework... Thanks for your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.