Comparing folder/sub-folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Comparing folder/sub-folder

#1 Post by newbie » 03 Nov 2010 02:45

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????

newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Re: Comparing folder/sub-folder

#2 Post by newbie » 03 Nov 2010 18:13

Nobody want to help????????

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Comparing folder/sub-folder

#3 Post by !k » 03 Nov 2010 20:58

You have not the same number of opening and closing brackets. Be careful.

newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Re: Comparing folder/sub-folder

#4 Post by newbie » 03 Nov 2010 22:02

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Comparing folder/sub-folder

#5 Post by !k » 03 Nov 2010 22:13

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"

newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Re: Comparing folder/sub-folder

#6 Post by newbie » 04 Nov 2010 00:07

why it should be like that? can u give me a reason?? :roll:

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Comparing folder/sub-folder

#7 Post by !k » 04 Nov 2010 00:25

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

newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Re: Comparing folder/sub-folder

#8 Post by newbie » 05 Nov 2010 19:22

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:

newbie
Posts: 24
Joined: 29 Sep 2010 01:30

Re: Comparing folder/sub-folder

#9 Post by newbie » 06 Nov 2010 01:54

nobody wanna help?

Post Reply