Copying certain files from folders

Microsoft Windows xp professional editio...
October 8, 2009 at 06:23:13
Specs: Windows XP
I have several folders that get created on a daily basis. For example:
20091001.000
20091002.000
20091003.000
Etc...

As you can see the date changes everyday for the folder name but .000 remains constant.

In these folders are daily reports in PDF format. I would like the ability to copy certain pdf's (not all) within these folders to another network drive keeping the folder structure the same on the drive that copies are being stored

So if the R: drive hosted folders:
20091001.000
20091002.000
20091003.000

I would want to copy the folders but only select pdfs from them to the H: drive. This wo uld be done on a daily basis

Currently I am using the following script:

for /d %%a in (R:\Reports\????????.000) do xcopy /e /i /-y "%%~fa" "H:\%%~nxa"

This copys all the contents of the folder from one drive to the other. Is there a way to modify this to copy specific files from fthe folder? if i have files daily called A.pdf B.pdf how would i adjust the command?

Any help would be appreciated

Thanks


See More: Copying certain files from folders

Report •


#1
October 8, 2009 at 06:49:39
Currently I am using the following script:

for /d %%a in (R:\Reports\????????.000) do xcopy /e /i /-y "%%~fa" "H:\%%~nxa"

This copys all the contents of the folder from one drive to the other. Is there a way to modify this to copy specific files from fthe folder? if i have files daily called A.pdf B.pdf how would i adjust the command?


Report •

#2
October 8, 2009 at 09:43:15
Do you only want the most recent A.pdf etc?


=====================================
Helping others achieve escape felicity

M2


Report •

#3
October 8, 2009 at 09:48:42
yes i was going to use the /d command to only upload changed files

Report •

Related Solutions

#4
October 8, 2009 at 10:14:38
Unless I'm missing the obvious, once you're current, you only need to copy the most recent folder's files.

This navigates itself to the most recent folder within R:\Reports and copies all the ?.pdfs.

====================================
@echo off & setLocal enableDELAYedexpansion

pushd R:\Reports

for /f "tokens=* delims= " %%a in ('dir/b/ad/o-n *.000') do (
pushd "%%a"
goto :done
)
:done

copy ?.pdf h:\


=====================================
Helping others achieve escape felicity

M2


Report •

#5
October 8, 2009 at 10:56:46
Thanks for the script it works yes and no.

To explain further this is more of what I want to do

R:/20091001.00/a.pdf copy to > H:/20091001.00/a.pdf
R:/20091002.00/a.pdf copy to > H:/20091002.00/a.pdf
R:/20091003.00/a.pdf copy to > H:/20091002.00/a.pdf
R:/20091004.00/a.pdf copy to > H:/20091002.00/a.pdf

Pretty much want a mirror image. and for it to create the same folder structure of YYYYMMDD.000 automatically

And then if the batch is run the next day, it wont try to recopy all the old folders again and only the new ones

Hope that better explains it!

Thanks for the assistance :)


Report •

#6
October 12, 2009 at 16:51:59
xcopy has a couple of options that migh help:
/M copies only those files that have the archive-bit set, and
switches off the archive bit (thus marking them as "copied"
and avoiding subsequent copying). You only need to verify
that the incoming files have this bit switched on ("attrib"
command shows "A" for the files.)
/Ddate copies only those files newer (more recent) than the
date specified after "D". this requires that the incoming files
dates are correct/synchronized with your system.
ps: it looks like, from viewing posts, Msft
would be doing a HUGE service if it had a
"mirror" utility w/various options. hey,
Bill G, like my idea? HIRE ME (just kidding)
(but submit only 15 million for the idea...thats nuts to you guys anyway, an i need it...

Report •

#7
October 13, 2009 at 08:39:31
how would i adjust this script for a specific file instead of the whole folder?

for /d %%a in (R:\Reports\????????.000) do xcopy /e /i /-y "%%~fa" "H:\%%~nxa"

This copies R:\YYYYMMDD.000 to H:\YYYYMMDD.000 and all its contents. I want it to be able to copy only certain files for example A.pdf.

I tried modifying the script the folllowing way but it is not working:

for /d %%a in (R:\Reports\????????.000\a.pdf) do xcopy /e /i /-y "%%~fa" "H:\%%~nxa"


Report •


Ask Question