将特定文件名从一个文件夹复制到另一个文件夹

5 windows-7

我在 Windows 上有一个文件夹,其中包含大约 200,000 个图像文件。我创建了一个文本文件,其中包含我需要复制的所有图像文件名,因此我可以将它们提取到一个新文件夹(大约 20,000 个)。每个图像都有一个特定的唯一文件名(例如 xb0001.jpg、图像 345766777.jpg 等)。

是否有任何程序/进程/批处理可以用来将文本文件中列出的每个图像从原始文件夹提取到新文件夹?

我对命令行有点陌生,所以如果批处理是一个解决方案,任何详细的帮助都会有很大的帮助

小智 5

从开始菜单中键入Powershell并单击Windows PowerShell出现的图标(它应该位于顶部)。

运行以下命令:

Get-Content c:\filestocopy.txt | ForEach-Object {copy-item $_ c:\newlocation}
Run Code Online (Sandbox Code Playgroud)

进行以下更改:

  1. c:\filestocopy.txt --> 使其成为您所说创建的文件
  2. c:\newlocation --> 将其设为您要将文件复制到的位置

以下是其作用的详细说明:

Get-Content c:\filestocopy.txt  --> This reads the file you created to be used later
| (pipeline)                    --> This is called a pipe. It takes the object from the left and passes it to the command on the right.
ForEach-Object {  }             --> This runs the commands between the brakets {} on each object that is passed from the pipe
copy-item  $_ c:\newlocation    --> Just what it says, it copies $_ to c:\newlocation
$_                              --> This is a variable, it contains the current item from the pipe
Run Code Online (Sandbox Code Playgroud)

以下是所有命令的链接:
Get-Content
ForEach-Object
Pipelines
Copy-Item
$_