how to get the maximum of filename of list file - VisualCron - Forum

Community forum

Gruyer
2022-06-13T09:50:28Z
Hi,
i have a list of file in a folder like this :
409.pdf
410.pdf
412.pdf
389.pdf
402.pdf ...

I'm trying to obtain the max of listed integer file name (412 in my example).

I don't how to combine variable to exclude (.pdf) of my list output and compare the list to obtain the maximum
Can you help me?
regards
Gary_W
2022-06-13T13:51:26Z
This powershell script will do the trick in one task. Assumption is filenames are in the format number.pdf.

(Get-ChildItem -Path 'Your path here\*' -Include *.pdf | % {$_.BaseName}| measure -Maximum).maximum


List all .pdf's in your path, remove the extension, get the maximum.
Gruyer
2022-06-13T14:55:12Z
thanks a lot, it works well 🙂
Michael Fjellström
2022-06-22T14:59:19Z
Originally Posted by: Gary_W 

This powershell script will do the trick in one task. Assumption is filenames are in the format number.pdf.

(Get-ChildItem -Path 'Your path here\*' -Include *.pdf | % {$_.BaseName}| measure -Maximum).maximum


List all .pdf's in your path, remove the extension, get the maximum.



Gary,

Thank you for the suggestion!
Gary_W
2022-06-22T15:01:50Z
Scroll to Top