I would like to write a short .bat script to compare the contents of two folders.
Folder 1: Contains some 1300 files.
Folder 2: Contains some 400 files.
I would like to have a script I can run through the windows command line that takes each file in Folder 2 checks to see if a file with the same name is in Folder 1... and if it is Outputs the name of the Folder 2 file to a .csv file (or notepad I'm easy just want a list!).
Any thoughts or help would be much appreciated!
try this
(for %%i in ("folder2\*") do if exist "folder1\%%~nxi" echo(%%~i)>file.csv
Found a solution that works with remote folders and is very fast
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set /p computer=Computer Name?:
set pubpath=\\%computer%\c$\docume~1\alluse~1\Desktop\
set results=excluded
set extension=txt
set xlist="ANHLIVE Desktop.lnk" "ANHLIVE EMR.lnk" "ImageNow.lnk" "IMPAX Client.lnk" "Internet Explorer.lnk" "Microsoft Excel 2010.lnk" "Microsoft Outlook 2010.lnk" "Microsoft Word 2010.lnk" "My Documents.lnk" "NextGen.RDP" "RBODowntimeLabel.doc" "desktop.ini"
set xlistcount=12
for /r %pubpath% %%g in (*) do (
set count=0
for %%a in (%xlist%) do (
set /a count=count+1
set localdir=%%a
set localdir=!localdir:~1,-1!
set remotedir=%%g
set remotedir=!remotedir:%pubpath%=!
if !localdir!==!remotedir! (
set count=12
) else (
if !count!==%xlistcount% (
echo !remotedir! >> %results%.%extension%
)
)
)
)
Echo Complete!
pause