In this example, I am scanning a book as one page per image. The scanning software saves each file with its own naming convention (sequentially). This is a selected sample listing (Windows):
d1 (1).jpg
d1 (2).jpg
d1 (5.5).jpg
d1 (10).jpg
d1 (21).jpg
d1 (100).jpg
d2 (1).jpg
d2 (2).jpg
d2 (67).jpg
I have hundreds of pages scanned over a two-day period (hence the 'd1' and 'd2'). At the end of day 1, I realized that I missed a page, scanned it and numbered it 5.5 (a page belonging in-between page 5 and page 6). This is why using the scanning software to create the ordering would not be feasible (if I continue to miss pages). I have written a command in powershell:
$x = 1
get-childitem -name | %{rename-item $_ -newname ('book p{0:D3}.jpg' -f $x++)}
It works perfectly, producing the following:
book p001.jpg
book p002.jpg
book p006.jpg
book p011.jpg
book p022.jpg
book p101.jpg
book p151.jpg
book p152.jpg
book p217.jpg
And again, this is just an example. There are many more pages. The output is what I am looking for. However, this doesn't do exactly as wanted. In PowerShell, if I do ls
, dir
, or Get-ChildItem
, I get the following:
d1 (1).jpg
d1 (10).jpg
d1 (100).jpg
d1 (2).jpg
d1 (21).jpg
d1 (5.5).jpg
d2 (1).jpg
d2 (2).jpg
d2 (67).jpg
As you can see, the ordering is different than what appears in Windows. I.e., page 'd1 (10)' will become 'p002' and not 'p011'. I'm thinking that one uses numerical ordering and the other uses strings. The question is, how can you get Powershell to present the list of file names as it appears in Windows?
Thank you