Need for Script (Batch file).
I need a batch file script that does this.
I have two locations (directories) in the computer: A and B.
Location A is where I will put the batch file. Location B is %appdata%\MyFolder (is not the real name).
Each of them has files and folders in it.
I want to make a batch file which, when started, will do this:
Copy specific files and folders(including their contents) from A (the batch file’s location) to B, without overwriting any files and folders in B that have the same names as those in A. In the batch file I should specify the files and folders to be copied from A to B.
After the batch file has finished copying the specified files and folders(including their contents) from A to B, it should wait for a specified number of seconds, for example 3.
After waiting for the number of seconds, the batch file should now do the reverse of step 1: that is, it will copy files and folders(including their contents) from B to A, without overwriting any files and folders in A that have the same names as those in B. In the batch file I should specify the files and folders to be copied from B to A.
After the batch file has copied the specified files and folders(including their contents) from B to A, it should wait for a specified number of seconds, for example 3.
Start again at Step 1, that is, copy from A to B.
It should do this endlessly (without using up too much memory and freezing or crashing the computer) as long as a file called MyProgram.exe (which is in %appdata%\MyFolder) is running. If MyProgram.exe is not running or has been closed, the batch file should finish any copying that it is doing, wait for a number of seconds which I specify ( e.g. 3), and if MyProgram.exe is still not running, the batch file should close itself.
While doing all the above, the batch file should be invisible: no window should show; it should not ask the user any questions; it should not overwrite any existing files or folders in either location while copying; no error messages should appear (for example, if I mentioned a file or folder that does not exist).
If the batch file is already running, another instance of it should NOT be allowed to open (e.g. if someone presses the file again). But no message should be shown, because the batch file works silently and invisibly.
What is the code for such a batch file? (I use Windows 7 32-bit, if that is important, but I want the batch file to work on any Windows version.)
Since I am going to specify certain variables, such as the files and folders to be copied between A and B, and how long the batch file waits before copying each time, my helper can indicate where I should insert those variables in his or her code.
I give thanks for any useful help.