1iJaCk icon

dodup.bat

1iJaCk | PRO | 07/04/17 08:41:49 PM UTC | 0 ⭐ | 170 👁️ | Never ⏰ | []
Batch |

4.66 KB

|

None

|

0 👍

/

0 👎

:: by JaCk | Release 07/04/2017 | https://pastebin.com/t1HXcwds | dodup.bat --- uses dupemerge.exe and wmic to locate and merge same files across all your partitions
@echo off && setlocal EnableDelayedExpansion && (for /f "tokens=1 delims==" %%a in ('set dodo_') do set "%%a=") 2>nul 1>nul
 
:::::::::::::::::::::::::::::::::::::::
::: User Settings :::::::::::::::::::::
::
set "dodo_DupeMergeBin="               rem Default: Not Set  --- If your dupemerge binary is not in %PATH% then you need to set this.  If you do not know, set this variable.
set "dodo_DupeMergeExclude=%windir%"   rem Default: %windir% --- This is the exclusion list for dupemerge, it shouldn't merge files on that list.
set "dodo_DupeMergeOutLog=%userprofile%\dodo.log"            rem Default: Not Set  --- If you want a log from dupemerge, set a desired qualified/reliative path and name of file, example -- %userprofile%\dmerge.log
set "dodo_DupeMergeQuiet=true"         rem Default: true     --- Tells dupemerge to be quiet. Suppressing any output.  This variable acts like a boolean.
set "dodo_ExcludedDriveLetters="       rem Default: Not Set  --- Tells this script to ignore these drive letters.  Space and/or Comma delineated list is fine. Example: C,F,D S M X
:::::::::::::::::::::::::::::::::::::::
 
 
 
:::::::::::::::::::::::::::::::::::::::
::: Pre-Processing and Error-Checking :
::
rem Checking elevated console, print msg and continue
call "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" 2>nul 1>nul || (
    echo/ 
    echo/ Warning: Info: Running in console without admin privileges, not all files can be linked.
    echo/ Info: Continuing.
    timeout /t 5
)
 
rem Checking for binary and searching the path when needed
rem when multiple binaries are located, scrpt will use the last one on the list.
if not defined dodo_DupeMergeBin (
    echo/
    for /f "tokens=1* delims=" %%a in ('where dupemerge.exe') do (
        echo/ Info: Bin: Found binary %%a
        set "dodo_DupeMergeBin=%%a"
    )
)
 
 
rem When Binary var is still unset, print error and leave script
if not defined dodo_DupeMergeBin (
    echo/
    echo/ Error: Fatal: dupemerge binary undefined, download and install it.
    echo/  Info: Direct Download link: http://www.schinagl.priv.at/nt/dupemerge/dupemerge.zip
    echo/  Info: Information Link: http://schinagl.priv.at/nt/dupemerge/dupemerge.html
    goto GimmeOuttaHere
)
 
 
rem Prepending -e param to the exclution param
if defined dodo_DupeMergeExclude (
    set "dodo_DupeMergeExclude=-e !dodo_DupeMergeExclude!"
)
 
 
rem stripping out double quotes from log path -- will be (re-)added later
if defined dodo_DupeMergeOutLog (
    set "dodo_DupeMergeOutLog=!dodo_DupeMergeOutLog:"=!"
)
 
 
rem Test to see if writable, unset variable when not, otherwise prepend the -o param.
if defined dodo_DupeMergeOutLog (
    (echo/) >> "!dodo_DupeMergeOutLog!" 
    if !errorlevel! equ 0 (
        set "dodo_DupeMergeOutLog=-o "!dodo_DupeMergeOutLog!""
    ) else (
        echo/
        echo/ Warning: Unable to to write to "!dodo_DupeMergeOutLog!"
        echo/ Info: LOG WILL NOT BE CREATED. Unsetting output log...
        echo/
        set "dodo_DupeMergeOutLog="
    )
)
 
 
rem quiet boolean check and set quiet param
if defined dodo_DupeMergeQuiet (
    echo !dodo_DupeMergeQuiet:~0,1! | findstr /i "y 1 t" 2>nul 1> nul
    if !errorlevel! equ 0 (
        set "dodo_DupeMergeQuiet=-q"
    ) else (
        set "dodo_DupeMergeQuiet="
    )
)
 
 
rem Checking Exclude Drive Filter and Adding "Name" to that list
rem wmic returns with a table title "Name" regardless of settings.
if defined dodo_ExcludedDriveLetters (
    set "dodo_ExcludedDriveLetters=Name !dodo_ExcludedDriveLetters!"
) else (
    set "dodo_ExcludedDriveLetters=Name"
)
:::::::::::::::::::::::::::::::::::::::
 
 
    
:::::::::::::::::::::::::::::::::::::::
::: Brians, give me your Brians... ::::
:: (yes, Brians. Dam you SPEL Police) :
::
echo/&echo/&echo/
echo/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
echo/_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_
for /f "delims=:" %%a in ('wmic logicaldisk get name ^| findstr /i "[A-Z]" ^| findstr /i /v "!dodo_ExcludedDriveLetters!"') do (
    echo/
    echo/  Info: Processing %%~a:\
    echo/  cmd: call "!dodo_DupeMergeBin!" !dodo_DupeMergeOutLog! !dodo_DupeMergeQuiet! %%~a:\ !dodo_DupeMergeExclude! 
    echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
    call "!dodo_DupeMergeBin!" !dodo_DupeMergeOutLog! !dodo_DupeMergeQuiet! %%~a:\ !dodo_DupeMergeExclude! 
    echo/ -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
)
echo/_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
echo/_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_~_
echo/
 
:::::::::::::::::::::::::::::::::::::::
 
:GimmeOuttaHere
rem unset all vars
(for /f "tokens=1 delims==" %%a in ('set dodo_') do set "%%a=") 2>nul 1>nul

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎