Hello,
I have a folder (D:\Images), which contains about 50 folders. Within these 50 folders are a sequence of 237 .tga images
The file names of each sequence are unique for each folder.. ie:
ImageA0001.tga... through ImageA0237.tga,
ImageDF0001.tga... through ImageDF0237.tga,
ImageB0001.tga... through ImageB0237.tga,
etc
I would like to copy two images from each sequence folder and paste these into 1 common folder.(D:\Images\Common)
the 2 images I'd like to copy are: *0001.tga, and *0007.tga
Any ideas how to achieve this?
Thanks for any help
Jeff
Bat file to copy specific files to common folder?
Moderator: DosItHelp
Re: Bat file to copy specific files to common folder?
This should work. Untested!
Code: Select all
@echo off
pushd D:\Images
FOR /F "delims=" %%G in ('dir /a-d /b /s *0001.tga *0007.tga' ^|findstr /I /V /B /C:"D:\Images\Common\"') do (
copy "%%~G" "D:\Images\common"
)
Re: Bat file to copy specific files to common folder?
That can copy some other files if the short filename matches the filespec as well.
This change might fix that possible issue:
Edit: added missing ^ character
This change might fix that possible issue:
Code: Select all
@echo off
pushd D:\Images
FOR /F "delims=" %%G in ('dir /a-d /b /s *.tga ^|findstr /i "0001.tga 0007.tga"^|findstr /I /V /B /C:"D:\Images\Common\"') do (
copy "%%G" "D:\Images\common"
)
Edit: added missing ^ character
Last edited by foxidrive on 20 Jul 2012 23:01, edited 1 time in total.
Re: Bat file to copy specific files to common folder?
foxidrive wrote:That can copy some other files if the short filename matches the filespec as well.
This change might fix that possible issue:Code: Select all
@echo off
pushd D:\Images
FOR /F "delims=" %%G in ('dir /a-d /b /s *.tga ^|findstr /i "0001.tga 0007.tga"|findstr /I /V /B /C:"D:\Images\Common\"') do (
copy "%%G" "D:\Images\common"
)
Thanks Foxidrive
Re: Bat file to copy specific files to common folder?
Awesome..works perfectly.!
Couldn't get the first code to work initially, but the one within Foxidrives' thread worked!
Thanks for all the help on this!
Very much appreciated.
Jeff
Couldn't get the first code to work initially, but the one within Foxidrives' thread worked!
Thanks for all the help on this!
Very much appreciated.
Jeff
Re: Bat file to copy specific files to common folder?
jeff p wrote:Awesome..works perfectly.!
Couldn't get the first code to work initially, but the one within Foxidrives' thread worked!
Thanks for all the help on this!
Very much appreciated.
Jeff
Really not much of a difference with our code. He just adds an extra PIPE to another FINDSTR. Technically both should work.