From Wikiversity - Reading time: 2 min
| This page may qualify for speedy deletion because: almost nothing to learn from here; it is a trivial wrapper for robocopy on Windows and cp -r on Linux; moving to user space or Draft archive is fine If you disagree or intend to fix it, and you have not contributed to it before, you may remove this notice. If you have contributed before and disagree, please explain why on the discussion page, after adding {{hangon}} to the top of the . This will alert curators and custodians to your intention, and may permit you the time to write your explanation. Before deleting check the discussion page, what links here, history (last edit), the page log, and Wikiversity:Deletions. |
@echo off IF [%1] EQU [] @echo "ERROR : Type in the Parameters" IF [%2] EQU [] @echo "ERROR : Type in the second Parameter" IF [%3] EQU [] @echo "ERROR : Type in the Time" :WHILE_0 if 1 EQU 1 ( @echo %~f1 %~f2 ROBOCOPY %~f1 %~f2 timeout %3% /NOBREAK goto WHILE_0 )
To run the Script open a Command Interpreter (CMD)

And type the name of the script in the console (it has to end with .bat):

than put in the two directories (left : where to copy from ), (right : where to copy to ) and the
Time delay you want (in seconds)

You can edit the script in any Text Editor you prefer.
CODE:
#!/bin/bash
# Checking for parameters
if [ $# -eq 0 ]; then
echo "Missing Parameters" >&2
exit 1
fi
if [ $# -eq 1 ]; then
echo "Type also the Second Parameter !" >&2
exit 1
fi
if [ $# -eq 2 ]; then
echo "Type also the Time Parameter !" >&2
exit 1
fi
if [ $# -eq 4 ]; then
echo "Too much Parameters !" >&2
exit 1
fi
#Defining PATH1, PATH2 and the Time in minutes
PATH1="$1"
PATH2="$2"
TIME="$3"
# endless loop until user stops it
# loop repeats in a predefined time an copys a directory with all subordinate directorys and files
while [ $((1)) == 1 ]; do
cp -r "$PATH1" "$PATH2"
echo "backed up !"
sleep "$TIME"m
done
To run the script open a command interpreter (Shell) and write the name with the argumens : ./YourProgramName: (where to copy from) (where to copy to) (time in minutes)