將特定檔案名稱從一個資料夾複製到另一個資料夾

將特定檔案名稱從一個資料夾複製到另一個資料夾

我在 Windows 上有一個資料夾,其中包含大約 200,000 個映像檔。我創建了一個文字文件,其中包含我需要複製的所有圖像文件名,因此我可以將它們提取到一個新資料夾(大約 20,000 個)。每個圖像都有一個特定的唯一檔案名稱(例如 xb0001.jpg、圖片 345766777.jpg 等)。

是否有任何程式/進程/批次可以用來將文字檔案中列出的每個圖像從原始資料夾提取到新資料夾?

我對命令列有點陌生,所以如果批次處理是一個解決方案,任何詳細的幫助都會有很大的幫助

答案1

從開始功能表中鍵入Powershell並點擊Windows PowerShell出現的圖示(它應該位於頂部)。

運行以下命令:

Get-Content c:\filestocopy.txt | ForEach-Object {copy-item $_ c:\newlocation}

進行以下更改:

  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

以下是所有指令的連結:
取得內容
ForEach-對象
管道
複製專案
$_

答案2

Windows 包含 For/if 組合,我更喜歡 DOS 命令,因為大多數錯誤已經解決,而更新且看似更強大的 shell 仍然存在可用性錯誤。

md YourDriveLetter\%date% set newdestination = "YourDriveLetter\%date%"

對於 (YourGraphicsFileList) 中的 /F %%t 執行複製 /q "%NewDestination%"

200,000 張圖片,老實說,這裡是男人對男人,男人收集 200,000 張照片的唯一一種是,是的,汽車照片!

Windows 甚至Mac 都很難解析出任何資料夾中的大量圖片,嘗試將它們精簡並按顏色、大小和形狀進行分組是一個值得的想法,但很耗時,但是嘿,沒有什麼比人們更喜歡的東西了獨自坐著,盯著汽車圖片,這樣您就可以享受整理每張照片的樂趣,同時定期休息一下,反思您剛剛看過的所有汽車。

相關內容