Skip to content

Commit

Permalink
Add option to robocopy folder structure only (exclude files)
Browse files Browse the repository at this point in the history
  • Loading branch information
GChuf committed May 4, 2022
1 parent 221535f commit e8638f2
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
87 changes: 87 additions & 0 deletions RCWM/files/RCopyStructure.bat
@@ -0,0 +1,87 @@
@echo off

rem 65000: UTF-7
rem 65001: UTF-8 does not work on Win7
chcp 65001 > nul

FOR /F "tokens=*" %%g IN ('powershell "$a='(default)'; if ( (Get-Item -Path Registry::HKCU\RCWM\rcs).property -eq $a) { echo 0 } else { echo (Get-Item -Path Registry::HKCU\RCWM\rcs).property }"') do (SET folder=%%g)

IF "%folder%" == 0 (
echo Source folder not specified!
echo Right-Click and select 'RoboCopy Structure'.
timeout /t 3 > nul
exit
) ELSE (
goto start )

:start

wmic process where name="cmd.exe" CALL setpriority 128 2>nul 1>nul
wmic process where name="conhost.exe" CALL setpriority 128 2>nul 1>nul

set curdir=%cd%

IF NOT EXIST "%folder%" (echo Source folder does not exist: %folder% && timeout /t 1 >nul && echo Exiting . . . && timeout /t 2 > nul && exit )
cd /d %folder%
for %%I in (.) do set fname=%%~nxI
cd /d "%curdir%"

IF EXIST "%fname%" (
goto :f1
) ELSE (
goto :f2
)

:f1
IF EXIST "%fname%\" (
echo Folder with the same name already exists: %fname%
goto :choice
) ELSE (
echo File with the same name already exists: %fname%
echo Cannot continue!
pause
exit
)

:f2
echo.
echo Copying . . .
echo.
md "%fname%"
robocopy "%folder%" "%fname%" /XF * /E /NP /NJH /NJS /NC /NS /MT:16
reg delete "HKCU\RCWM\rcs" /f >NUL
reg add "HKCU\RCWM\rcs" /f >NUL
echo Finished!
timeout /t 1 1>NUL
exit

:choice
choice /C moc /M "Merge/Overwrite/Cancel?"
goto option%errorlevel%

:option1
echo.
echo Merging . . .
echo.
robocopy "%folder%" "%fname%" /XF * /E /NP /NJH /NJS /NC /NS /XC /XN /XO /MT:16
reg delete "HKCU\RCWM\rcs" /f >NUL
reg add "HKCU\RCWM\rcs" /f >NUL
echo Finished!
timeout /t 1 1>NUL
exit

:option2
echo.
echo Overwriting . . .
echo.
robocopy "%folder%" "%fname%" /XF * /E /NP /NJH /NJS /NC /NS /MT:16
reg delete "HKCU\RCWM\rcs" /f >NUL
reg add "HKCU\RCWM\rcs" /f >NUL
echo Finished!
timeout /t 1 1>NUL
exit

:option3
echo Exiting . . .
timeout /t 1 1>NUL
exit
21 changes: 21 additions & 0 deletions RCWM/files/RCopyStructure.reg
@@ -0,0 +1,21 @@
Windows Registry Editor Version 5.00

;robocopy

[HKEY_CLASSES_ROOT\Directory\shell\rcopys]
@="RoboCopy Structure"
"NoWorkingDirectory"=""
"Icon"="rcwmimg.dll,-5"

[HKEY_CLASSES_ROOT\Directory\shell\rcopys\command]
@="cmd.exe /c chcp 65001 > nul && reg delete \"HKCU\\RCWM\\rcs\" /f > nul && reg add \"HKCU\\RCWM\\rcs\" /v \"%V\" /t REG_SZ > nul"
"IsolatedCommand"="cmd.exe /c chcp 65001 > nul && reg delete \"HKCU\\RCWM\\rcs\" /f > nul && reg add \"HKCU\\RCWM\\rcs\" /v \"%V\" /t REG_SZ > nul"

[HKEY_CLASSES_ROOT\Directory\Background\shell\rpastes]
@="RoboPaste Structure"
"Icon"="rcwmimg.dll,-6"
[HKEY_CLASSES_ROOT\Directory\Background\shell\rpastes\command]
@="cmd.exe /c C:\\Windows\\System32\\RCWM\\RcopyStructure.bat"
"IsolatedCommand"="cmd.exe /c C:\\Windows\\System32\\RCWM\\RcopyStructure.bat"

; end
6 changes: 6 additions & 0 deletions RCWM/install.cmd
Expand Up @@ -16,6 +16,7 @@ rem after v1.5
reg delete "HKCU\RCWM" /f >NUL
reg add "HKCU\RCWM" /f >NUL
reg add "HKCU\RCWM\rc" /f >NUL
reg add "HKCU\RCWM\rcs" /f >NUL
reg add "HKCU\RCWM\mv" /f >NUL
reg add "HKCU\RCWM\mir" /f >NUL
reg add "HKCU\RCWM\dl" /f >NUL
Expand Down Expand Up @@ -188,6 +189,11 @@ if %errorlevel% == 1 ( start /w regedit /s MvDir.reg && goto Other ) else ( star

:Other

color c
choice /C yn /M "* Do you want to add RoboCopy to copy Folder Structure only (exclude files) "
if %errorlevel% == 1 ( start /w regedit /s RCopyStructure.reg )


color b
choice /C yn /M "* Do you want to add open CMD to background/folders/drives "
if %errorlevel% == 1 ( start /w regedit /s CMD.reg )
Expand Down
9 changes: 9 additions & 0 deletions RCWM/uninstall/Remove_RoboCopyStructure.reg
@@ -0,0 +1,9 @@
Windows Registry Editor Version 5.00

;Remove RoboCopy from context menu

[-HKEY_CLASSES_ROOT\Directory\shell\rcopys]

[-HKEY_CLASSES_ROOT\Directory\Background\shell\rpastes]

; end

0 comments on commit e8638f2

Please sign in to comment.