locked
Printing list of the certain pdf files from two folders RRS feed

  • Question

  • Hi folks,

    I have a working script:

    $ex = New-Object -ComObject Excel.Application
    $ex.Visible = 1
    $wb = $ex.Workbooks.Open("C:\Users\meli\Desktop\Eli-column.xlsx")
    $ws = $wb.Worksheets.Item(1)
    
    $result = @()
    
    [int]$rmax = $ws.Range("G65536").End(-4162).Row
    $ws.Range("G1:G$rmax") | Where {$_.Value2} | Foreach {
    	$col = $_.Column+1
    	$row = $_.Row
    	$val = $ws.Cells.Item($row,$col)
    	
    	$result += [pscustomobject]@{
    		Invoices = $_.Value2
    		Values = $val.Value2
    	}
    }
    	
    $result | Where {!$_.Values} | Foreach {Start-Process -FilePath "s:\Invoices-SD-from-documentum\0070\$($_.Invoices).pdf" –Verb Print}
    $ex.Quit()

    that selects certain numbers of invoices,   and prints appropriated PDF files  from the 1 folder. How to change the script so that he was looking for invoices numbers ( pdf  files) in two folders and print them


    nesher13

    Thursday, May 14, 2015 9:18 AM

Answers

  • So you have to modify the script to print twice - once for each folder.

    $result | Where {!$_.Values} | Foreach{
        Start-Process -FilePath "s:\folder1\0070\$($_.Invoices).pdf" Verb Print
        Start-Process -FilePath "s:\folder2\0070\$($_.Invoices).pdf" Verb Print
    }


    \_(ツ)_/

    • Marked as answer by nesher13 Friday, May 15, 2015 4:46 AM
    Thursday, May 14, 2015 5:03 PM

All replies

  • What have you tried? How about running the scrip twice once with each file.

    \_(ツ)_/

    Thursday, May 14, 2015 1:50 PM
  • There is a file Excel, in one of the columns of which are invoices numbers

    There are pdf files,corresponding to these numbers,which are located in the different folders.

    It is necessary to print these files


    nesher13

    Thursday, May 14, 2015 4:52 PM
  • So you have to modify the script to print twice - once for each folder.

    $result | Where {!$_.Values} | Foreach{
        Start-Process -FilePath "s:\folder1\0070\$($_.Invoices).pdf" Verb Print
        Start-Process -FilePath "s:\folder2\0070\$($_.Invoices).pdf" Verb Print
    }


    \_(ツ)_/

    • Marked as answer by nesher13 Friday, May 15, 2015 4:46 AM
    Thursday, May 14, 2015 5:03 PM