Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Unfortunately transferring our design programs databases to a new computer for a clean install, does not also transfer custom textures (bitmap) to that new computer. Consequently I have to manually compare all the bitmaps and only copy the unmatching files to the destination graphics folder. All the custom and system textures are all mixed up in the same folder.
I would like a batch file to compare the files in the source and destination folders and only copy the unmatched files to a new folder called "custom bitmaps".
In addition, I would like to filter out all file names that contain terms like "system" or "stock" (for example: stock door0377.bmp)Can this be done fairly easily?
Thanks for the help!

@echo off
dir /B /A-D \Destination> EXCLIST.TXT
xcopy /I /EXCLUDE:EXCLIST.TXT "\Source\*.*" "\Custom bitmaps"::To filter out the filenames
pushd "\Custom bitmaps"
dir /B /A-D | find "system"> DELLIST.TXT
dir /B /A-D | find "stock">> DELLIST.TXT
for /F "tokens=* delims=" %%j in (DELLIST.TXT) do del "%%j"
popd
del ???LIST.TXT
:: [End_Of_Batch]BEWARE: batch not tested

Thanks for writing this out for me. I appreciate the efforts of the members here, so I'm making an effort to learn batch "coding" and not just "take the code and run".
I've been studying this batch file for a while, and while I follow some of it, I have a few questions about things I can't find in the help files.
(And thanks for the heads-up that it hasn't been tested. I'm certainly not going to run it on "live" files without making sure it will work on some test files first.)
On the second line I'm not sure I follow the {\Destination> EXCLIST.TXT} part. Does this ">" create a txt file in the specified path [destination]?
That's the first question.
Thanks for the help!

Ah! I think I've got it. See if this is correct for the second line.
dir /B /A-D \Destination> EXCLIST.TXT
--------------------
List directory with bare format (no heading etc.) and displayfiles with specified attributes (-not directories) in the specified path
[destination = D:\Database ] and ">" [REDIRECT] the directory list to text file "EXCLIST.TXT"
--------------------Thanks for the help!

Now for the third line.
xcopy /I /EXCLUDE:EXCLIST.TXT "\Source\*.*" "\Custom bitmaps"
----------------
Sum up: copy all files [excluding exclist.txt] files from "source" [specify path] to destination [assume path = directory "custom bitmaps"].
----------------Does this create the folder "Custom Bitmaps"?
Thanks for the help!

Yes, you are right.
The Dir command creates a list of all files stored in your new Database directory and stores it into EXCLIST.TXT.
Then the Xcopy command uses that list to copy the customer's bitmaps from the old directory (to be coded) to the new created "Custom bitmaps" (generated while coying) excluding the files listed in EXCLIST.TXT.
The lower section of the script creates a list of files to be deleted (filtered as I understood from your original post) based on the words "system" or "stock" in the name and then browses that by a For /F statement to drive the deletion process.
Now I have partially tested that and so here the final version
@echo off
dir /B /A-D \Destination> EXCLIST.TXT
xcopy /I /EXCLUDE:EXCLIST.TXT "\Source\*.*" "\Custom bitmaps"
del EXCLIST.TXT:: [Filter out the filenames]
pushd "\Custom bitmaps"
dir /B /A-D | find "system"> DELLIST.TXT
dir /B /A-D | find "stock">> DELLIST.TXT
for /F "tokens=* delims=" %%j in (DELLIST.TXT) do del "%%j"
del DELLIST.TXT
popd
:: [End_Of_Batch]

I rewrote this a bit to test it, but I can't get the files to copy to the second folder. What am I doing wrong?
----------------------
@echo offMkDir E:\Test1
type Nul > "E:\Test1\frazzle.jpig"
type Nul > "E:\Test1\frizzle.jpig"
type Nul > "E:\Test1\system door.jpig"
type Nul > "E:\Test1\frozzle.jpig"
type Nul > "E:\Test1\stock door.jpig"
type Nul > "E:\Test1\stockdoor.jpig"
type Nul > "E:\Test1\systemtexture.jpig"MkDir E:\Test2
dir /B /A-D E:\Test1> EXCLIST.TXT
xcopy /I /EXCLUDE:EXCLIST.TXT "E:\Test1\*.*" "E:\Test2"
del EXCLIST.TXT:: [Filter out the filenames]
pushd "E:\Test2"
dir /B /A-D | find "system"> DELLIST.TXT
dir /B /A-D | find "stock">> DELLIST.TXT
for /F "tokens=* delims=" %%j in (DELLIST.TXT) do del "%%j"
del DELLIST.TXT
popd
:: [End_Of_Batch]Thanks for the help!

Hmmm....
If I take the "exclude" command out, it all works as expected.
What's up with that?
--------------
@echo off
MkDir E:\Test1
type Nul > "E:\Test1\frazzle.jpig"
type Nul > "E:\Test1\frizzle.jpig"
type Nul > "E:\Test1\system door.jpig"
type Nul > "E:\Test1\frozzle.jpig"
type Nul > "E:\Test1\stock door.jpig"
type Nul > "E:\Test1\stockdoor.jpig"
type Nul > "E:\Test1\systemtexture.jpig"MkDir E:\Test2
dir /B /A-D E:\Test1> EXCLIST.TXT
xcopy /I "E:\Test1\*.*" "E:\Test2"
::/EXCLUDE:EXCLIST.TXTdel EXCLIST.TXT
:: [Filter out the filenames]
pushd "E:\Test2"
dir /B /A-D | find "system"> DELLIST.TXT
dir /B /A-D | find "stock">> DELLIST.TXT
for /F "tokens=* delims=" %%j in (DELLIST.TXT) do del "%%j"
del DELLIST.TXT
popd
:: [End_Of_Batch]Thanks for the help!

You have to exclude the file you previously transferred to the new system, so you have to create the exclude list by issuing a Dir command to the Database directory of the new system. That holds system files only. Then xcopy from the old Database directory where system and custom files are mixed so excluding the system files to be copied.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |