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????
Comparing folder/sub-folder
Moderator: DosItHelp
Re: Comparing folder/sub-folder
Nobody want to help????????
Re: Comparing folder/sub-folder
You have not the same number of opening and closing brackets. Be careful.
Re: Comparing folder/sub-folder
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!!
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!!
Re: Comparing folder/sub-folder
BecauseI don't know why
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
why it should be like that? can u give me a reason??
Re: Comparing folder/sub-folder
Try
anddir /b/s ""C:\Program Files\Common Files""
dir /b/s C:\Program Files\Common Files
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
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??????