Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.000I 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

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?

Do you only want the most recent A.pdf etc?
=====================================
Helping others achieve escape felicityM2

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 enableDELAYedexpansionpushd R:\Reports
for /f "tokens=* delims= " %%a in ('dir/b/ad/o-n *.000') do (
pushd "%%a"
goto :done
)
:donecopy ?.pdf h:\
=====================================
Helping others achieve escape felicityM2

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.pdfPretty 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 :)

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...

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"

![]() |
enter file path to a vari...
|
print the song The Twelve...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |