diff --git a/CopyDates.bat b/CopyDates.bat index 4f2e57b..8f317e0 100644 --- a/CopyDates.bat +++ b/CopyDates.bat @@ -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 \ No newline at end of file diff --git a/PasteDates.bat b/PasteDates.bat index 25eb949..76b379b 100644 --- a/PasteDates.bat +++ b/PasteDates.bat @@ -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" -) \ No newline at end of file + rename "%WINCPD%\DATES" "%FILENAME%" + robocopy "%WINCPD%" "%FOLDER%" "%FILENAME%" /COPY:T + rename "%WINCPD%\%FILENAME%" "DATES" +) + +:pause \ No newline at end of file