-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcp.bat
More file actions
24 lines (24 loc) · 617 Bytes
/
cp.bat
File metadata and controls
24 lines (24 loc) · 617 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@echo off
setlocal enabledelayedexpansion
set "recurse=0"
set "force="
:parse
if "%~1"=="" goto args_done
if /I "%~1"=="-r" (set "recurse=1" & shift & goto parse)
if /I "%~1"=="-f" (set "force=/Y" & shift & goto parse)
:args_done
if "%~1"=="" (echo Usage: cp [-r] [-f] ^<src^> ^<dest^> & exit /b 1)
if "%~2"=="" (echo cp: missing destination operand & exit /b 1)
set "SRC=%~1"
set "DST=%~2"
if exist "%SRC%\NUL" (
if "%recurse%"=="1" (
robocopy "%SRC%" "%DST%" /E >nul
) else (
echo cp: -r not specified; omitting directory "%SRC%"
exit /b 1
)
) else (
copy %force% "%SRC%" "%DST%" >nul
)
endlocal