Author Posts

October 20, 2016 at 7:47 pm

Hi guys,

New to the forum (and to Powershell if I'm honest)

I have a problem I'm hoping someone can point me in the right direction to solve – I have to merge two CSV files, adding a header and trailer (which is fine), the resulting output CSV (named with date/time stamp) will then be sent to a supplier.

This will be a daily task and as such the suppliers format specifies that a unique file transaction/sequence number is included in the header – basically 1 for the first file and so on. For the life of me I can't find out how to do this, referencing the previous sequence number and incrementing daily.

Any tips or pointers would be greatly appreciated

Thanks in advance

October 20, 2016 at 8:04 pm

So, could you not store a starting value in a file?

1 | Out-File lastvalue.txt

And then...

$lastvalue = [int](Get-Content lastvalue.text)
$todaysvalue = $lastvalue++
$todaysvalue | out-file lastvalue.txt

?

October 20, 2016 at 8:10 pm

I will give that a go and get back to you, thanks for the quick reply – great forum, I'm sure I'll be spending a lot of time here!