Solved Batch/Robocopy Script To Compare Folders and Files

July 29, 2013 at 00:08:01
Specs: Windows 7, AMD 8 Core, 32GB Ram
Good day all

I am look for help building a batch or Robocopy script to do the following:

Compare the files & folders in folder A; to the files & folders of folder B; I then would like to copy the difference to Folder C for further analysis?

Is there any way to achieve this?

Kind Regards
Tor Fey


See More: Batch/Robocopy Script To Compare Folders and Files

Report •


#1
July 29, 2013 at 02:11:34
✔ Best Answer
::====== script starts here ===============
::
:: TorFey.bat 2013-07-29 15:53:55.32
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in ('dir/b A\') do (
if not exist B\%%a (
copy A\%%a C
)
)

:sub1
for /f "tokens=* delims= " %%a in ('dir/b B\') do (
if not exist A\%%a (
copy B\%%a C
)
)
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

#2
July 29, 2013 at 02:37:34
Hi Mechanix2Go

Many thanks for the reply, if i wanted to promp the user for the drive letters; how would i go about that?

Many Thanks
Tor Fey


Report •

#3
July 29, 2013 at 03:01:35
set/p letterONE= first drive letter ?

... and so on

=====================
M2 Golden-Triangle


Report •

Related Solutions

#4
July 29, 2013 at 04:40:50
So would that be like this:

::====== script starts here ===============
::
:: TorFey.bat 2013-07-29 15:53:55.32
@echo off & setLocal enableDELAYedeXpansioN
set/p letterONE=
set/p letterTWO=
set/p letterTHREE=
:main
for /f "tokens=* delims= " %%a in ('dir/b A\') do (
if not exist B\%%a (
copy A\%%a C
)
)

:sub1
for /f "tokens=* delims= " %%a in ('dir/b B\') do (
if not exist A\%%a (
copy B\%%a C
)
)
goto :eof
::====== script ends here =================


Report •

#5
July 29, 2013 at 08:33:57
::====== script starts here ===============
::
:: TorFey2.bat 2013-07-29 15:53:55.32
@echo off & setLocal enableDELAYedeXpansioN

set/p i=
set/p j=
set/p k=

for /f "tokens=* delims= " %%a in ('dir/b !i!') do (
if not exist !j!%%a (
copy !i!%%a !k!
)
)
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

Ask Question