帮助-Powershell [英] Help -Powershell

查看:140
本文介绍了帮助-Powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我老了,累了,退休了....我刚学会了PowerShell和RoboCopy的存在。我有几本15年前的VB Scripting书籍,并且在10多年前写了4个脚本。所以现在我已经准备好了....



我想帮助一位朋友从旧电脑上取下照片并通过USB线连接到新的便携式硬盘驱动器上。他不知道"在哪里"照片位于或如果它们都在一个地方。我可以完成这项工作,但我想学习PS
并编写一个可以"查找"的脚本。所有.jpg并将该信息传递给Robocopy。我的猜测是使用find * .jpg> Photos.txt并使用grep以某种方式将其解析为Robocopy。或者可能有更好的方法来做到这一点。任何想法真的会
被赞赏。也许可以通过电子邮件发送给我在sgo1 at gmx-dot-com

解决方案


您可以使用 $ b带有 -Recurse -Include'* .jpg'
参数的$ b Copy-Item
cmdlet可搜索并复制到外部驱动器。


每件事都将使用一个班轮完成。



例如:

#using Verbose你可以看到发生了什么
Copy-Item -Path c:\ -Include'* .jpg'-Recurse -Destination f:\ -Verbose


问候,


Kvprasoon


I'm old and tired and retired.... I've just learned the existence of PowerShell and RoboCopy. I've got a couple of 15-year old VB Scripting books and wrote maybe 4 scripts with over 10 years ago. So now that I've got that laid out....

I want to help a friend get his photos off of an old computer and onto a new portable hard drive via a USB cable. He doesn't know "where" the photos are located or if they are all in one place. I can get this done, but I'd like to learn about PS and write a script that can "Find" all .jpg's and pass that info to Robocopy. My guess is using find *.jpg > Photos.txt and use grep to parse that out to Robocopy somehow. Or maybe there's an even better way to do that. Any ideas would really be appreciated. maybe email it to me at sgo1 at gmx-dot-com

解决方案

Hi ,

You can use Copy-Item cmdlet with -Recurse and -Include '*.jpg' parameters to search and copy to the external drive.

every thing will be done using a one liner.

example:

# using Verbose you can see what is happening
Copy-Item -Path c:\ -Include '*.jpg' -Recurse -Destination f:\ -Verbose

Regards,

Kvprasoon


这篇关于帮助-Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆