Powershell Get-ChildItem 进度问题
所以,我在一个文件夹中有一组目录 00-99。每个目录都有 100 个子目录,00-99。每个子目录都有数千张图像。
我想做的基本上是在计算平均文件大小时获得进度报告,但我无法让它发挥作用。这是我当前的查询:
get-childitem <MyPath> -recurse -filter *.jpeg
| Where-Object { Write-Progress "Examining File $($_.Fullname)" true }
| measure-object -Property length -Average
这向我显示了一个随着每个文件的处理而更新的栏,但最后我没有返回平均文件大小数据。显然,我做错了什么,因为我认为尝试破解Where-Object来打印进度语句可能是一个坏主意(tm)。
由于有数以百万计的图像,这个查询显然需要很长时间才能完成。如果我理解正确的话, get-childitem 几乎将占据查询时间的大部分。有什么指示可以得到我想要的东西吗? AKA,我的结果理想情况下是:
Starting...
Examining File: \00\00\Sample.jpeg
Examining File: \00\00\Sample2.jpeg
Examining File: \00\00\Sample3.jpeg
Examining File: \00\00\Sample4.jpeg
...
Examining File: \99\99\Sample9999.jpg
Average File Size: 12345678.244567
编辑:我可以做一个简单的选择:
get-childitem <MyPath> -recurse -filter *.jpeg
| measure-object -Property length -Average
然后离开我的工作站一天半或其他时间,但这似乎有点低效=/
So, I've got a set of directories 00-99 in a folder. Each of those directories has 100 subdirectories, 00-99. Each of those subdirectories has thousands of images.
What I'm attempting to do is basically get a progress report while it's computing the average file size, but I can't get that to work. Here's my current query:
get-childitem <MyPath> -recurse -filter *.jpeg
| Where-Object { Write-Progress "Examining File $($_.Fullname)" true }
| measure-object -Property length -Average
This shows me a bar that updates as each of the files gets processed, but at the end I get back no average file size data. Clearly, I'm doing something wrong, because I figure trying to hack the Where-Object to print a progress statement is probably a bad idea(tm).
Since there are millions and millions of images, this query obviously takes a VERY LONG time to work. get-childitem is pretty much going to be the bulk of query time, if I understand things correctly. Any pointers to get what I want? AKA, my result would ideally be:
Starting...
Examining File: \00\00\Sample.jpeg
Examining File: \00\00\Sample2.jpeg
Examining File: \00\00\Sample3.jpeg
Examining File: \00\00\Sample4.jpeg
...
Examining File: \99\99\Sample9999.jpg
Average File Size: 12345678.244567
Edit: I can do the simple option of:
get-childitem <MyPath> -recurse -filter *.jpeg
| measure-object -Property length -Average
And then just walk away from my workstation for a day and half or something, but that seems a bit inefficient =/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西吗?
Something like this?
更详细一点的进展:
A little more detailed progress: