Page 1 of 1

Copy file with selective extension and create original folde

Posted: 25 Jul 2011 07:51
by darioit
Hello,

I have this new issue, copy from backup only jpg picture after restore partition

Original data:
Z:
¦-------PICTURE
¦ +---NIKON
¦ +---2010-02-10
¦ DSC_00005.JPG
¦ DSC_00005.NEF
¦ +---2010-02-11
¦ DSC_00015.JPG
¦ DSC_00015.NEF


I want to copy all root folder "PICTURE" to new disk with same folder structure, but only JPG extension

Result after copy expected:
D:
¦-------IMAGE
¦ +---NIKON
¦ +---2010-02-10
¦ DSC_00005.JPG
¦ +---2010-02-11
¦ DSC_00015.JPG

I try to execute this script, but I don't know how to create first a new folder before copy file jpg file.

@echo off &setlocal
for /f "tokens=* delims=" %%a in ('dir *.jpg /a-d /b /s "Z:\PICTURE\"') do (
copy %%~a D:\IMAGE\%right_folder%"
)
pause

Regards
Dario

Re: Copy file with selective extension and create original f

Posted: 25 Jul 2011 08:52
by !k
Use xcopy instead copy. Example:
xcopy /is C:\from\*.JPG D:\to\

Re: Copy file with selective extension and create original f

Posted: 25 Jul 2011 09:03
by darioit
Superb! many thanks
Dario