Time : 2014-12-01 12:13:11 Program : BatCodeCheck, Version 0.32.1 beta Arguments : "C:\Scripts\RoboMove.bat" /H File name : "C:\Scripts\RoboMove.bat" File date : 2014-10-09 00:30:00 1@ECHO OFF 2:: Check Windows version 3IF NOT "%OS%"=="Windows_NT" GOTO Syntax 4 5:: Enable delayed variable expansion 6SETLOCAL ENABLEDELAYEDEXPANSION 7 8:: Check command line arguments 9ECHO.%* | FINDSTR /R /C:"[?\*]" >NUL && GOTO Syntax 10IF "%~2"=="" GOTO Syntax 11IF NOT "%~3"=="" IF /I NOT "%~3"=="/ROBOCOPY" GOTO Syntax 12IF NOT EXIST "%~f1.\" GOTO Syntax 13IF NOT EXIST "%~f2.\" GOTO Syntax 14 15:: Initialize variables 16SET Files1= 17SET Files2= 18SET Temp1= 19SET Temp2= 20SET Title= 21 22:: Save the current title if possible 23FOR /F "tokens=*" %%A IN ('GetTitle2.exe /NC /NP 2^>NUL') DO SET Title=%%A Unterminated percent signs. 24 25:: Navigate to the first folder, giving it a drive letter on the fly in case of a UNC type path 26PUSHD "%~f1" >NUL 2>&1 || GOTO Syntax 27FOR %%A IN ("%CD%") DO SET Files1="%%~dpA*.*" 28POPD 29 30:: Navigate to the second folder, giving it a drive letter on the fly in case of a UNC type path 31PUSHD "%~f2" >NUL 2>&1 || GOTO Syntax 32FOR %%A IN ("%CD%") DO SET Files2="%%~dpA*.*" 33POPD 34 35:: Navigate to the TEMP folder 36PUSHD "%Temp%" >NUL 2>&1 || GOTO Syntax 37FOR %%A IN ("%CD%") DO ( 38 SET Temp1="%%~dpA%~n0.tmp" 39 SET Temp2="%%~dpA%~n0.tmp" 40) 41POPD 42 43:: Create 2 lists of files to be uodated 44XCOPY %Files1% %Files2% /S /D /H /R /Y /L | FIND "\" > %Temp1% Variable "%FILES1%" found with delayed variable expansion enabled; shouldn't th 45XCOPY %Files2% %Files1% /S /D /H /R /Y /L | FIND "\" > %Temp2% Variable "%FILES2%" found with delayed variable expansion enabled; shouldn't th 46 47:: Replicate the directory structure of source on target 48XCOPY %Files1% %Files2% /T /E /Y >NUL 2>&1 Variable "%FILES1%" found with delayed variable expansion enabled; shouldn't th 49 50:: Count the number of files moved and directories created 51SET FilesMoved=0 52 53:: For each file in the first list ... 54FOR /F "tokens=*" %%A IN ('TYPE %Temp1%') DO ( Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't tha 55 TITLE %%A Unterminated percent signs. 56 REM :: ... check for duplicates on either drive 57 SET Error=0 58 TYPE FIND /C /I "%%~nxA" %Temp1% | FINDSTR /R /X /C:"1" >NUL || SET Error=1 Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't tha 59 TYPE FIND /C /I "%%~nxA" %Temp2% | FINDSTR /R /X /C:"1" >NUL || SET Error=1 Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't tha 60 REM :: If no duplicates were found ... 61 IF !Error! EQU 0 ( 62 REM ... find the location of the file to be moved ... 63 FOR /F "tokens=*" %%B IN ('FINDSTR /R /E /I /C:"\\%%~nxA" %Temp2%') DO ( Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't tha 64 REM :: ... move the file to its new location 65 SET /P "=%%~fB -> %%~dB%%~pA " < NUL 66 MOVE "%%~fB" "%%~dB%%~pA" 67 SET /A FilesMoved += 1 68 ) 69 ) ELSE ( 70 ECHO Skipped "%%~A" ^(duplicates or not found^) 71 ) 72) 73 74IF %FilesMoved% EQU 1 ( Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn' 75 ECHO Moved 1 file. 76 TITLE Moved 1 file. 77) ELSE ( 78 ECHO Moved %FilesMoved% files. Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn' 79 TITLE Moved %FilesMoved% files. Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn' 80) 81 82:: Run ROBOCOPY if specified 83IF /I "%~3"=="/ROBOCOPY" ( 84 SET Options= 85 SET Counter=0 86 FOR %%A IN (%*) DO ( 87 SET /A Counter += 1 88 IF !Counter! GTR 3 ( 89 IF /I NOT "%%~A"=="/MIR" ( 90 SET Options=!Options! %%A Unterminated percent signs. 91 ) 92 ) 93 ) 94 ROBOCOPY "%~f1" "%~f2" /MIR !Options! 95) 96 97:Clean up 98IF DEFINED Title TITLE %Title% Variable "%TITLE%" found with delayed variable expansion enabled; shouldn't tha 99DEL %Temp1% >NUL 2>&1 Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't tha 100DEL %Temp2% >NUL 2>&1 Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't tha 101ENDLOCAL 102GOTO:EOF 103 104 105:Syntax 106ECHO. 107ECHO RoboMove.bat, Version 0.30 beta 108ECHO Move files in the target folders to natch their location in the source folder. 109ECHO If run before RoboCopy, the latter won't have to delete moved files and then 110ECHO copy them again to their new location (most useful on network drives). 111ECHO. 112ECHO Usage: ROBOMOVE source_folder target_folder 113ECHO ROBOCOPY source_folder target_folder /MIR [ robocopy_options ] 114ECHO. 115ECHO or: ROBOMOVE source_folder target_folder /ROBOCOPY [ robocopy_options ] 116ECHO. 117ECHO Where: source_folder the source folder, used as a template for the target 118ECHO target_folder the target folder, where the files will be moved to 119ECHO match the source folder as closely as possible 120ECHO /ROBOCOPY run ROBOCOPY /MIR on the specified folders afterwards 121ECHO robocopy_options are the switches passed on to ROBOCOPY 122ECHO. 123ECHO Notes: Folders MUST be specified as fully qualified paths, either in 124ECHO drive:\path or UNC format; do not specify files. 125ECHO. 126ECHO Written by Rob van der Woude 127ECHO http://www.robvanderwoude.com 128 129IF "%OS%"=="Windows_NT" ENDLOCAL 130IF "%OS%"=="Windows_NT" EXIT /B 1 131 ERRORS / VULNERABILITIES: Line 23: Unterminated percent signs Line 44: Variable "%FILES1%" found with delayed variable expansion enabled; shouldn't that be "!FILES1!" instead? Line 45: Variable "%FILES2%" found with delayed variable expansion enabled; shouldn't that be "!FILES2!" instead? Line 48: Variable "%FILES1%" found with delayed variable expansion enabled; shouldn't that be "!FILES1!" instead? Line 54: Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't that be "!TEMP1!" instead? Line 55: Unterminated percent signs Line 58: Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't that be "!TEMP1!" instead? Line 59: Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't that be "!TEMP2!" instead? Line 63: Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't that be "!TEMP2!" instead? Line 74: Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn't that be "!FILESMOVED!" instead? Line 78: Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn't that be "!FILESMOVED!" instead? Line 79: Variable "%FILESMOVED%" found with delayed variable expansion enabled; shouldn't that be "!FILESMOVED!" instead? Line 90: Unterminated percent signs Line 98: Variable "%TITLE%" found with delayed variable expansion enabled; shouldn't that be "!TITLE!" instead? Line 99: Variable "%TEMP1%" found with delayed variable expansion enabled; shouldn't that be "!TEMP1!" instead? Line 100: Variable "%TEMP2%" found with delayed variable expansion enabled; shouldn't that be "!TEMP2!" instead? SUMMARY: 16 lines generated warnings and should be examined 3 unterminated percent signs were found Note that some warnings are only displayed once. Correct the errors and run this test again.