-
Notifications
You must be signed in to change notification settings - Fork 17
/
backbat2.bat
66 lines (39 loc) · 1.43 KB
/
backbat2.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@echo off
rem
rem backbat.bat -- Backup batch files (Windows 95/98/ME version)
rem
rem usage: backbat backupdir
rem where: backupdir is the directory to copy batch files
rem all batch files in the current directory will
rem be backed up
rem
rem Make sure that there is at least one argument
if not "%1"=="" goto argsok
echo usage: %0 backupdir
echo where: backupdir is the directory to copy batch files
echo all batch files in the current directory will
echo be backed up
goto end
:argsok
rem Save the backup directory
set backupdir=%1
rem Check to make sure that the backupdir exists and isn't a file
if not exist %backupdir% goto notfile
echo %backupdir% is a file
goto end
:notfile
rem If the directory does not exist, create it. Because we can't reliably
rem check the errorlevel in Windows 95/98/ME, check if the directory exists
rem after we do the make directory command.
if exist %backupdir%\nul goto skipdir
md %backupdir%
if exist %backupdir%\nul goto skipdir
echo Error creating backup directory
goto end
:skipdir
rem Copy each batch file one at a time by calling our subroutine.
rem Note: the for loop variable (%%b) must be contain only one letter.
for %%b in ( *.bat ) do copy %%b %backupdir% > nul
:end
rem Clean up: unset our variable
set backupdir=