Page 1 of 1

Comparing folder/sub-folder

Posted: 03 Nov 2010 02:45
by newbie
Hi, sorry to disturb again, actually I really need this problem need to be solved urgently. I just wrote a batch program that comparing files which look like this:

set thumbdrive1="E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"
set harddisk1="C:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"

set /p d1="Specify your source folder (pendrive): "
set /p d2="Specify your destination folder (harddisk): "

for /f "delims=" %%i in ('dir /b/a-d "%thumbdrive1%\%d1%\*" "%harddisk1%\%d2%\*"^|sort') do (
call set "$i=%%$i:%%i=%%"
if defined $i (
if not exist "%harddisk1%\%d2%\%%i" (echo :. +: %%i) else (
fc "%thumbdrive1%\d1%\%%i" "%harddisk1%\%d2%\%%i" >nul&& echo := =: %%i|| echo :^< ^>: %%i)))
set "$i=%%i"
)


When I run it, it prompted "there was an unexpected error )", what I don't understand is why the it cannot through sub-folder or do I have to change the coding again???? please need help here urgently????

Re: Comparing folder/sub-folder

Posted: 03 Nov 2010 18:13
by newbie
Nobody want to help????????

Re: Comparing folder/sub-folder

Posted: 03 Nov 2010 20:58
by !k
You have not the same number of opening and closing brackets. Be careful.

Re: Comparing folder/sub-folder

Posted: 03 Nov 2010 22:02
by newbie
It's solved!! I just remove the "" in:
for /f "delims=" %%i in ('dir /b/a-d %thumbdrive1%\%d1%\* %harddisk1%\%d2%\*^|sort') do (
call set "$i=%%$i:%%i=%%"
if defined $i (
if not exist %harddisk1%\%d2%\%%i (echo :. +: %%i) else (
fc %thumbdrive1%\d1%\%%i %harddisk1%\%d2%\%%i >nul&& echo := =: %%i|| echo :^< ^>: %%i)))
set "$i=%%i"
)
It worked but I don't know why..Anyway, thanx a lot!! :D

Re: Comparing folder/sub-folder

Posted: 03 Nov 2010 22:13
by !k
I don't know why
Because
set thumbdrive1="E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"
set harddisk1="C:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"

Right it must be
set "thumbdrive1=E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"
set "harddisk1=C:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"

Re: Comparing folder/sub-folder

Posted: 04 Nov 2010 00:07
by newbie
why it should be like that? can u give me a reason?? :roll:

Re: Comparing folder/sub-folder

Posted: 04 Nov 2010 00:25
by !k
Try
dir /b/s ""C:\Program Files\Common Files""
dir /b/s C:\Program Files\Common Files
and
dir /b/s "C:\Program Files\Common Files"


Z:\>set "thumbdrive1=E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"

Z:\>echo "%thumbdrive1%\stuff"
"E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook\stuff"

Z:\>set thumbdrive1="E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"

Z:\>echo %thumbdrive1%\stuff
"E:\Pendrive\PC Wizard Info\eGovt\eBIS-7 Notebook 185 Desktop\7 Notebook"\stuff

Re: Comparing folder/sub-folder

Posted: 05 Nov 2010 19:22
by newbie
Thanks once again for the useful help, at this moment I'm trying to compare folder from local disk and USB drive. But the thing is the folder is like 100 to 300 folders and even if I'm trying to compare, I have to go through it one by one, is there any possible way for me to go through it at once????need help?????? :cry:

Re: Comparing folder/sub-folder

Posted: 06 Nov 2010 01:54
by newbie
nobody wanna help?