Skip to content

Commit

Permalink
1.0.1 fixed Robocopy's 'drunk' behaviour with trailing backslash
Browse files Browse the repository at this point in the history
  • Loading branch information
minch-dev committed Sep 19, 2021
1 parent eb0c979 commit e564b22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
17 changes: 11 additions & 6 deletions CopyDates.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
echo off
set FULLPATH=%1
set FOLDER=%2
set FILNAME=%~nx1
SetLocal EnableDelayedExpansion

set FILENAME=%~nx1
set TRAILING=!FILENAME:~-1!
if !TRAILING!==\ set FILENAME=!FILENAME:~0,-1!

set FOLDER=%~2
set TRAILING=!FOLDER:~-1!
if !TRAILING!==\ set FOLDER=!FOLDER:~0,-1!
set WINCPD=%TMP%\WinCPD

: /DCOPY:T
del /F /Q "%WINCPD%\DATES"
robocopy "%FOLDER%" "%WINCPD%" "%FILNAME%" /COPY:T /CREATE
rename "%WINCPD%\%FILNAME%" "DATES"
robocopy "%FOLDER%" "%WINCPD%" "%FILENAME%" /COPY:T /CREATE
rename "%WINCPD%\%FILENAME%" "DATES"

:pause
22 changes: 15 additions & 7 deletions PasteDates.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
echo off
set FULLPATH=%1
set FOLDER=%2
set FILNAME=%~nx1
SetLocal EnableDelayedExpansion

set FILENAME=%~nx1
set TRAILING=!FILENAME:~-1!
if !TRAILING!==\ set FILENAME=!FILENAME:~0,-1!

set FOLDER=%~2
set TRAILING=!FOLDER:~-1!
if !TRAILING!==\ set FOLDER=!FOLDER:~0,-1!
set WINCPD=%TMP%\WinCPD

IF EXIST "%WINCPD%\DATES" (
rename "%WINCPD%\DATES" "%FILNAME%"
robocopy "%WINCPD%" "%FOLDER%" "%FILNAME%" /COPY:T /DCOPY:T
rename "%WINCPD%\%FILNAME%" "DATES"
)
rename "%WINCPD%\DATES" "%FILENAME%"
robocopy "%WINCPD%" "%FOLDER%" "%FILENAME%" /COPY:T
rename "%WINCPD%\%FILENAME%" "DATES"
)

:pause

0 comments on commit e564b22

Please sign in to comment.