Advertisement
J2897

Robocopy - Fix Permissions

Oct 13th, 2015
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.31 KB | None | 0 0
  1. :: Released under the GNU General Public License version 3 by J2897.
  2.  
  3. :: This script will get the file security information from the files in the
  4. :: SOURCE folders and add them to the appropriate files in the DESTINATION
  5. :: folders.
  6.  
  7. @echo OFF
  8.  
  9. ver | find "Version 6." > nul
  10. if %ERRORLEVEL% == 0 (
  11.     REM Do OPENFILES to check for administrative privileges
  12.     openfiles > nul
  13.     if errorlevel 1 (
  14.         color cf
  15.         echo.Right-click on this file and select 'Run as administrator'.
  16.         pause
  17.         color
  18.         exit /b 1
  19.     )
  20. )
  21.  
  22. REM Custom variables.
  23. set "TASKNAME=Fix Permissions"
  24. set "TASKNAME=Fix NAS1 Sec"
  25. set "SOURCE=\\NAS1\FreeNAS\J2897\Android\Apps\Installed"
  26. set "DESTINATION=J:\NAS1 Mirror\Android\Apps\Installed"
  27.  
  28. REM Fixed variables.
  29. set "LOGFOLDER=%USERPROFILE%\RoboCopy Logs"
  30. set "LOGFILE=%LOGFOLDER%\%TASKNAME%.log"
  31. set "TAB=   "
  32.  
  33. REM Preparation.
  34. title %TASKNAME%
  35. pushd "%~dp0"
  36. if not exist "%LOGFOLDER%" (md "%LOGFOLDER%")
  37.  
  38. REM Display.
  39. echo Fixing permissions . . .
  40. echo.
  41. echo SOURCE:%TAB%%TAB%%SOURCE%
  42. echo DESTINATION:%TAB%%DESTINATION%
  43.  
  44. REM Main RoboCopy command.
  45. robocopy.exe "%SOURCE%" "%DESTINATION%" *.* /E /Copy:S /IS /IT /NS /NP /R:100 /W:30 /Z /LOG:"%LOGFILE%"
  46.  
  47. REM Finish up.
  48. explorer /select,"%LOGFILE%"
  49. popd
  50. echo.
  51. pause
  52.  
  53. :End
  54. echo.
  55. echo Ending . . .
  56. timeout /t 4 /nobreak >nul
  57. exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement