简体   繁体   中英

Copy the first file from every folder to a new location in windows

I have a folder with about 100-200 subfolders. All these have 20-30 Jpegs each. I wish to copy only the first Jpeg file from all the subfolders to a New Folder. Is there a way to automate this?

Thanks!

Use a script like vbScript:

 Const rootFolder = "c:\\Rootfolder" Const targetFolder = "c:\\TargetFolder" Set fso = CreateObject("Scripting.FileSystemObject") For Each objFolder In fso.GetFolder(rootFolder).SubFolders i = 0 For Each sFile In objFolder.Files If i = 0 then fso.GetFile(sFile).Copy targetFolder & "\\" & fso.GetFileName(sFile),True i = 1 End if Next Next

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM