Go Back   Velocity Reviews > Newsgroups > Computer Support
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Computer Support - BAT file - XCOPY, way to exclude a folder(s)?

 
Thread Tools Search this Thread
Old 10-21-2003, 12:06 AM   #1
Default BAT file - XCOPY, way to exclude a folder(s)?


I've got 3 great working bat files using XCOPY. It would be nice if
one of them could exclude a folder but I can't find anything on the
net re this. The /EXCLUDE command didn't work and I didn't realize it
was for just files until I didn't get results (I'm quite a newbie re
bat file creation. I'm an expert at using, but not at creating <g>!).

The bat file is below, and as an fyi, there are 2 MD commands in it
because it's one of 3 XCOPY ones. All 3 of them create a folder
within the main "FldrStruct2Bckup" one referenced. Just wanted to
explain why the two MD steps are necessary. Here is the bat as it
stands now:


@ECHO OFF
ECHO.
MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
''START MENU''"
XCOPY /T /E "C:\WINDOWS\Start Menu"
"C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of ''START
MENU''" /-Y
ECHO.

Since I have a separate bat like this just for the PROGRAMS folder in
the start menu, want this bat above to exclude it that folder from the
XCOPYing process. Any way to do this?

Thanks!



fitwell
  Reply With Quote
Old 10-21-2003, 01:50 AM   #2
SirOsisOfThuliver
 
Posts: n/a
Default Re: BAT file - XCOPY, way to exclude a folder(s)?
fitwell wrote:

> I've got 3 great working bat files using XCOPY. It would be nice if
> one of them could exclude a folder but I can't find anything on the
> net re this. The /EXCLUDE command didn't work and I didn't realize it
> was for just files until I didn't get results (I'm quite a newbie re
> bat file creation. I'm an expert at using, but not at creating <g>!).
>
> The bat file is below, and as an fyi, there are 2 MD commands in it
> because it's one of 3 XCOPY ones. All 3 of them create a folder
> within the main "FldrStruct2Bckup" one referenced. Just wanted to
> explain why the two MD steps are necessary. Here is the bat as it
> stands now:
>
>
> @ECHO OFF
> ECHO.
> MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
> MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
> ''START MENU''"
> XCOPY /T /E "C:\WINDOWS\Start Menu"
> "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of ''START
> MENU''" /-Y
> ECHO.
>
> Since I have a separate bat like this just for the PROGRAMS folder in
> the start menu, want this bat above to exclude it that folder from the
> XCOPYing process. Any way to do this?
>
> Thanks!
>
>


The XCOPY's /EXCLUDE:file parm should work. Include something like this
in your batch file:

echo \directoryname\ > excludefile.txt
echo excludefile.txt >> excludefile.txt
..
..
..
del excludefile.txt

The first echo command creates the .txt file with the directory name to
be excluded by XCOPY. The second echo appends the name of the file
itself to the .txt file, so that xcopy will exclude it. And, finally,
the exclude file is deleted when the XCOPY has completed.



SirOsisOfThuliver
  Reply With Quote
Old 10-22-2003, 01:28 AM   #3
fitwell
 
Posts: n/a
Default Re: BAT file - XCOPY, way to exclude a folder(s)?
On Mon, 20 Oct 2003 19:50:58 -0500, SirOsisOfThuliver
<> wrote:

>>fitwell wrote:


[snip]

>The XCOPY's /EXCLUDE:file parm should work. Include something like this
>in your batch file:
>
>echo \directoryname\ > excludefile.txt
>echo excludefile.txt >> excludefile.txt
>.
>.
>.
>del excludefile.txt


Argggh, my brain just isn't managing this today <g>. I've made so
many other strides in other areas over last couple of days, I guess
this is just one thing too many to try to wrap my brain around. I'm
understanding the concept somewhat, but obviously not totally because
I can't yet see how a text file is involved in terms of coding it into
the bat file. <?>

One file yesterday did reference a text file, but I didn't understand
that that was part of the syntax and not a completely separate
function being coded into the bat.

The folder to exlude in the above bat is this one:

C:\WINDOWS\Start Menu\Programs

How would I fit that into the bat file below, all the text file
parameters?:

>> @ECHO OFF
>> ECHO.
>> MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
>> MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
>> ''START MENU''"
>> XCOPY /T /E "C:\WINDOWS\Start Menu"
>> "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of ''START
>> MENU''" /-Y
>> ECHO.


[snip]

>The first echo command creates the .txt file with the directory name to
>be excluded by XCOPY. The second echo appends the name of the file
>itself to the .txt file, so that xcopy will exclude it. And, finally,
>the exclude file is deleted when the XCOPY has completed.


Is a text file actually created, btw? And, if so, is it automatically
deleted after the process is completed?

Thanks!



fitwell
  Reply With Quote
Old 10-22-2003, 12:32 PM   #4
SirOsisOfThuliver
 
Posts: n/a
Default Re: BAT file - XCOPY, way to exclude a folder(s)?
fitwell wrote:

> On Mon, 20 Oct 2003 19:50:58 -0500, SirOsisOfThuliver
> <> wrote:
>
>
>>>fitwell wrote:
>>>

>
> [snip]
>
>
>>The XCOPY's /EXCLUDE:file parm should work. Include something like this
>>in your batch file:
>>
>>echo \directoryname\ > excludefile.txt
>>echo excludefile.txt >> excludefile.txt
>>.
>>.
>>.
>>del excludefile.txt
>>

>
> Argggh, my brain just isn't managing this today <g>. I've made so
> many other strides in other areas over last couple of days, I guess
> this is just one thing too many to try to wrap my brain around. I'm
> understanding the concept somewhat, but obviously not totally because
> I can't yet see how a text file is involved in terms of coding it into
> the bat file. <?>
>
> One file yesterday did reference a text file, but I didn't understand
> that that was part of the syntax and not a completely separate
> function being coded into the bat.
>
> The folder to exlude in the above bat is this one:
>
> C:\WINDOWS\Start Menu\Programs
>
> How would I fit that into the bat file below, all the text file
> parameters?:
>
>
>>>@ECHO OFF
>>>ECHO.
>>>MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
>>>MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
>>>''START MENU''"
>>>XCOPY /T /E "C:\WINDOWS\Start Menu"
>>>"C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of ''START
>>>MENU''" /-Y
>>>ECHO.
>>>

>
> [snip]
>
>
>>The first echo command creates the .txt file with the directory name to
>>be excluded by XCOPY. The second echo appends the name of the file
>>itself to the .txt file, so that xcopy will exclude it. And, finally,
>>the exclude file is deleted when the XCOPY has completed.
>>

>
> Is a text file actually created, btw? And, if so, is it automatically
> deleted after the process is completed?
>
> Thanks!
>
>



I added the statements to create and delete an "exclude file" to your
batch file, below, as well as added the /EXCLUDE parameter to the XCOPY
command. I left, as is, a couple of things that didn't look right to me.
For example,

1. The "/T" parameter on the XCOPY command will cause it to "create a
directory structure, but not copy files."

I haven't tested this, but my understanding is: It will copy NO files.
It creates directories, only. Was that your intention? If not, you'll
need to remove the /T. Maybe it works differently in your version of
Windows. I'll leave that to you to verify.

2. In multiple places, you have embedded quotation marks. That is, you
have a quoted string within a larger quoted string. I've never tried
that in a batch file. Does it cause an error?

Below, line 6 and 7 create a file named excludefile.txt. The directory
that you want to exclude, "C:\WINDOWS\Start Menu\Programs", is copied to
that file. The name of the file itself, excludefile.txt, is then copied
(appended, actually) to the file. Line 11 deletes the file after the
XCOPY has completed.



@ECHO OFF
ECHO.
MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
"START MENU""
echo "C:\WINDOWS\Start Menu\Programs" > excludefile.txt
echo excludefile.txt >> excludefile.txt
XCOPY /T /E /EXCLUDE:excludefile.txt "C:\WINDOWS\Start Menu"
"C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of "START
MENU"" /-Y
del excludefile.txt
ECHO.



SirOsisOfThuliver
  Reply With Quote
Old 10-22-2003, 07:07 PM   #5
fitwell
 
Posts: n/a
Default Re: BAT file - XCOPY, way to exclude a folder(s)?
On Wed, 22 Oct 2003 06:32:59 -0500, SirOsisOfThuliver
<> wrote:

>fitwell wrote:
>
>> On Mon, 20 Oct 2003 19:50:58 -0500, SirOsisOfThuliver
>> <> wrote:


[snip]

>>>The first echo command creates the .txt file with the directory name to
>>>be excluded by XCOPY. The second echo appends the name of the file
>>>itself to the .txt file, so that xcopy will exclude it. And, finally,
>>>the exclude file is deleted when the XCOPY has completed.
>>>

>>
>> Is a text file actually created, btw? And, if so, is it automatically
>> deleted after the process is completed?
>>
>> Thanks!
>>
>>

>
>
>I added the statements to create and delete an "exclude file" to your
>batch file, below, as well as added the /EXCLUDE parameter to the XCOPY


Thank you!

>command. I left, as is, a couple of things that didn't look right to me.
>For example,


>1. The "/T" parameter on the XCOPY command will cause it to "create a
>directory structure, but not copy files."
>
>I haven't tested this, but my understanding is: It will copy NO files.
>It creates directories, only. Was that your intention? If not, you'll
>need to remove the /T. Maybe it works differently in your version of
>Windows. I'll leave that to you to verify.


Yes. Most definitely. The 3 bats are just to back up folder
structures and content is not desirable in this case. I don't like
imaging backups; my installation is just too dynamic for this type of
backup procedure to work. I much prefer to do a wipe and then
reinstall as I go. I may eventually get to the point where I feel I
can image that first basic installation but even if that's the case,
will need to keep a current backup of the folder structures of 3
folders at present: the start menu both the programs and the portion
above that and my c:\program files. I have an efficient way of
installing everything by category but it'll be nice when I can just
dump the structure into the 3 main roots files after a clean
reinstall.

>2. In multiple places, you have embedded quotation marks. That is, you
>have a quoted string within a larger quoted string. I've never tried
>that in a batch file. Does it cause an error?


No. I put them in because the bat didn't work otherwise in this
sense: I try to avoid using DOS 8.3 file format where a bat like this
can act as a template that I can modify for other uses - much easier
to make changes. It's tough to see the coding otherwise sometimes.
But if you use the LFN, the bat never works without encapsulating the
pathname in quotation marks. I learned that trick along the way
somewhere and I use it whenever I need to reference LFN vs 8.3. (When
there is no need for long pathname, I just use the 8.3 one which I
easily get through using one of the apps I can't live without - a PC
Mag shell extension called Path Copy.)

>Below, line 6 and 7 create a file named excludefile.txt. The directory
>that you want to exclude, "C:\WINDOWS\Start Menu\Programs", is copied to
>that file. The name of the file itself, excludefile.txt, is then copied
>(appended, actually) to the file. Line 11 deletes the file after the
>XCOPY has completed.


Ah, that's what I thought. One would have to write in a cleaup line.

>@ECHO OFF
>ECHO.
>MD C:\WINDOWS\DESKTOP\FldrStruct2Bckup
>MD "C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of
>"START MENU""
>echo "C:\WINDOWS\Start Menu\Programs" > excludefile.txt
>echo excludefile.txt >> excludefile.txt
>XCOPY /T /E /EXCLUDE:excludefile.txt "C:\WINDOWS\Start Menu"
>"C:\WINDOWS\DESKTOP\FldrStruct2Bckup\BACKUP of upper part of "START
>MENU"" /-Y
>del excludefile.txt
>ECHO.


Super, wow! Looks good. I'm going to try it out and report back.

Trouble with being a power user newbie is not only do I have enough
knowledge to get myself into but not out of trouble, sometimes, but
things can still can get so overwhelming. This was one of those
times. Thanks for helping me out!

Cheers! D



fitwell
  Reply With Quote
Old 09-09-2009, 10:14 AM   #6
vincecup17
Junior Member
 
Join Date: Sep 2009
Posts: 4
Default ANOTHER question
i just want to copy only the folders in a particular directory say for example

i have directory:
C:\japan\WF_SCRIPTS_FILES\JSTR_DLOAD

under that directory there is 1 directory
\20090909.16.14.26
along with 10 files.

i just want to copy the \20090909.16.14.26 folder and anything under it
to C:\japan\WF_SCRIPTS_FILES\Backup\JSTR



thanks a lot!
and onte thing, how to start a thread?


vincecup17
vincecup17 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SONY DVD RW DW-G120A SOMETIMES FAILS...... atlantic965 DVD Video 0 06-18-2006 10:36 PM
problems backing up dvds Lawrence Traub DVD Video 11 09-27-2005 07:34 PM
Re: Ripping DVDs. Please answer the attached question. - Question.txt Stan Brown DVD Video 19 02-09-2005 11:19 PM
Burn process failed - help! Log file posted for help troubleshooting Michael Mason DVD Video 1 08-16-2004 09:24 PM
Pioneer A05 Problems Bill Stock DVD Video 8 11-28-2003 05:03 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46