I need to retrieve pdf file and copy this pdf file from source to destination. The pdf name are in txt file listspec one number by line :
100
200
204
79002
XS002
I concatenate the .pdf
extension
But the pdf files are 00100.pdf, 00200.pdf, 20400.pdf, 79002.pdf, XS002.pdf. I need to Padleft with 0 the pdf file name on 5 positions max.
I use this command :
Get-Content $listspec | Foreach-Object{copy-item -Path $source\$_".pdf".PadLeft(5,'0'), -destination $destination -ErrorAction SilentlyContinue -ErrorVariable +errors}
I receive this error :
*Copy-Item : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter ' method is not supported.*
Thanks for your help.