Here is a good example on how to do a command if a file does or does not exist:
if exist C:\myprogram\sync\data.handler echo Now Exiting && Exit if not exist C:\myprogram\html\data.sql Exit
We will take those three files and put it in a temporary place. After deleting the folder, it will restore those three files.
xcopy "test" "C:\temp" xcopy "test2" "C:\temp" del C:\myprogram\sync\ xcopy "C:\temp" "test" xcopy "C:\temp" "test2" del "c:\temp"
Use the XCOPY command:
xcopy "C:\myprogram\html\data.sql" /c /d /h /e /i /y "C:\myprogram\sync\"
I will explain what the /c /d /h /e /i /y means:
/C Continues copying even if errors occur. /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. /H Copies hidden and system files also. /E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T. /T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes /I If destination does not exist and copying more than one file, assumes that destination must be a directory. /Y Suppresses prompting to confirm you want to overwrite an existing destination file. `To see all the commands type`xcopy /? in cmd
Call other batch file with option sync.bat myprogram.ini.
I am not sure what you mean by this, but if you just want to open both of these files you just put the path of the file like
Path/sync.bat Path/myprogram.ini
If it was in the Bash environment it was easy for me, but I do not know how to test if a file or folder exists and if it is a file or folder.
You are using a batch file. You mentioned earlier you have to create a .bat file to use this:
I have to create a .BAT file that does this: