473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DOS shellscript. How to compare and synchronise directories?

2 New Member
The scripts takes two paths to folders as parameters and 1) compares them and shows the files/folders that are present in the first folder and not in the second and vice versa 2) If there are differences in the contents of the two folders then synchronises both folders' contents. In addition, if the file is present in both folders then it copies the latest file (date modified) to the folder with the older version of the file. The SYNC somehow doesn't work...
Expand|Select|Wrap|Line Numbers
  1. @echo off
  2.  
  3. if "%1" == "" goto MAARAMATA
  4. if not exist %1 goto PUUDUB
  5. for /R %1 %%i in (.) do call :COMPARE "%%i"
  6. for /R %1 %%i in (.) do call :SYNC "%%i"
  7.  
  8. goto END
  9.  
  10. :MAARAMATA
  11. echo.
  12. echo No folder specified.
  13.  
  14. :PUUDUB
  15. echo.
  16. echo That folder does not exist.
  17.  
  18. :COMPARE
  19. findstr "%1" "%2" /s
  20.  
  21. :SYNC
  22.  
  23. XCOPY "%1" "%2" /D /I
  24. XCOPY "%2" "%1" /D /I
  25.  
  26. goto END
  27.  
  28.  
  29. :END
  30.  
Nov 22 '10 #1
0 1265

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4516
by: Robin Siebler | last post by:
I have two directory trees that I want to compare and I'm trying to figure out what the best way of doing this would be. I am using walk to get a list of all of the files in each directory. I...
4
3630
by: could ildg | last post by:
I want to compare 2 directories, and find If all of theire sub-folders and files and sub-files are identical.. If not the same, I want know which files or folders are not the same. I know filecmp...
0
1625
by: Kaan ?cg?n | last post by:
Hello NG, we have created a database for our schedules on the SQL server 2000. As we have many satellite stations, we created a merge publication. The aim of this merge publication is to provide...
1
2030
by: Koen | last post by:
Hi all, I have built different databases for managing data I keep for my digital collections of mp3's, e-book's, divx movies and digital photographs. Until now, all these solutions lack one...
3
4756
by: Michael Thomas | last post by:
Hi everyone Is there any way to compare tables and automatically update values. I import a list of products with associated cost prices and selling prices from an external database into a table...
8
2391
by: Peter Larsen [] | last post by:
Hi, If i have a mapped drive and an UNC path - both pointing to the same directory on the server, how do i determine if they match (point to the same directory on the server) ?? Thank you....
3
1888
by: could.net | last post by:
I want to compare 2 directories: dir1 and dir2. What I want to do is to get these informations: 1. does they have the same number of files and sub-directories? 2. does each file with the same name...
5
5560
by: stamatis32 | last post by:
Hello everybody, i want to make a prog to compare the contents of 2 dirs. You can compare easily 2 files, but how this happend with dirs. I am very confused, i dont know where to start from, can...
1
1626
by: Richard | last post by:
I'm writing code to compare two directories side-by-side, like FolderMatch or FolderSync. I've used ListBoxes in VB6, so have the idea about concatenating strings for list items, but have no...
2
2930
by: Rahul83 | last post by:
Hi.. I'm new to Perl programming. I need to compare two directories of similar structure... check all the subdirectories in it and generate a report of the changes in the files in all the...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.