Copy file with selective extension and create original folde

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Copy file with selective extension and create original folde

#1 Post by darioit » 25 Jul 2011 07:51

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Copy file with selective extension and create original f

#2 Post by !k » 25 Jul 2011 08:52

Use xcopy instead copy. Example:
xcopy /is C:\from\*.JPG D:\to\

darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Re: Copy file with selective extension and create original f

#3 Post by darioit » 25 Jul 2011 09:03

Superb! many thanks
Dario

Post Reply