ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Sync folders by renaming files

<< < (4/6) > >>

4wd:
is there any way it can announce how many files were checksummed and how many were renamed?-DyNama (June 03, 2013, 12:30 PM)
--- End quote ---

Yes, the more direct way would however require you to stop using ! in filenames since Delayed Expansion would need to be enabled.

But there's probably a more creative way around the problem.

V5 with statistics and colour!  ;D

I fixed the reversed srce/dest in the rename section where I had it backwards.


--- Code: Text [email protected] (@CodeSection == @Batch) @then     @echo off    color 1a    setlocal EnableExtensions    setlocal DisableDelayedExpansion        echo Select SOURCE folder    for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (        if %%S=="" exit        set srce=%%S    )    echo Selected folder: "%srce%"        echo Select DESTINATION folder    for /F "delims=" %%D in ('CScript //nologo //E:JScript "%~F0"') do (        if %%D=="" exit       set dest=%%D    )    echo Selected folder: "%dest%"        set /P ext=Please enter extension [eg. jpg]:     if %ext%=="" exit    set /a totfiles=0    set /a renfiles=0        for /r "%srce%" %%a in (*.%ext%) do (call :CheckSize "%dest%" %%~za "%%~fa"):End    echo Total files:   %totfiles%    echo Renamed files: %renfiles%    set totfiles=    set renfiles=    set srce=    set dest=    set ext=    pause    exit     :CheckSize    set /a totfiles+=1    for /r %1 %%b in (*.%ext%) do (if %2 equ %%~zb call :CheckDate "%~3" "%%~b")    goto :EOF     :CheckDate    if "%~t1" equ "%~t2" (        pushd "%~dp2"        ren "%~nx2" "%~nx1"        if not exist "%~nx2" (set /a renfiles+=1)        popd    )    goto :EOF     endlocal     End of Batch [email protected]  // JScript section // Creates a dialog box that enables the user to select a folder and display it.var title = "Select a folder", rootFolder = 0x11;var shl = new ActiveXObject("Shell.Application");var folder = shl.BrowseForFolder(0, title, 0, rootFolder);WScript.Stdout.WriteLine(folder ? folder.self.path : "");

DyNama:
done, mouser, from my meager resources.

4wd, wonderful!

so is it actually checking all 3 criteria, size, date, and checksum?

one more request. when RenSS finishes, could it loop back and ask for another extension using the same 2 folders, and only exit when i hit {enter}?

4wd:
so is it actually checking all 3 criteria, size, date, and checksum?-DyNama (June 04, 2013, 07:57 PM)
--- End quote ---

No - you said it wasn't finding any matches when it used the checksums, so that's not in this version.  It's just size, date and time.

Besides unless I can find a way to get it to work with Delayed Expansion enabled and ! in filenames I can't use the MD5 routine since it relies on Delayed Expansion.

one more request. when RenSS finishes, could it loop back and ask for another extension using the same 2 folders, and only exit when i hit {enter}?
--- End quote ---

Easy enough.

V6 Added repeatability and fixed cancelling of folder requesters.
V7 Added log file and option to display at end, (written to same folder as batch file), it just keeps getting bigger until you delete it


--- Code: Text [email protected] (@CodeSection == @Batch) @then     @echo off    color 1a    setlocal EnableExtensions    setlocal DisableDelayedExpansion        echo Select SOURCE folder    for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (        set srce=%%S    )    if "%srce%"=="" goto :End2    echo Selected folder: "%srce%"        echo Select DESTINATION folder    for /F "delims=" %%D in ('CScript //nologo //E:JScript "%~F0"') do (       set dest=%%D    )    if "%dest%"=="" goto :End2        echo Selected folder: "%dest%"        :GetExt    echo.    set /P ext=Please enter extension [eg. jpg] ENTER to exit:     if %ext%=="" goto :End2    set /a totfiles=0    set /a renfiles=0     echo --------------------------- >>"%~dp0%RenSSDT.log"    echo %date%  %time% >>"%~dp0%RenSSDT.log"    echo --------------------------- >>"%~dp0%RenSSDT.log"     for /r "%srce%" %%a in (*.%ext%) do (call :CheckSize "%dest%" %%~za "%%~fa")     :End    echo Total files:   %totfiles%    echo Renamed files: %renfiles%    set totfiles=    set renfiles=    set ext=    if exist "%~dp0%RenSSDT.log" (        choice /c yn /m "View logfile"        if errorlevel 2 goto :GetExt        if errorlevel 1 (start notepad.exe "%~dp0%RenSSDT.log")    )    goto :GetExt    :End2    set srce=    set dest=    pause    exit     :CheckSize    set /a totfiles+=1    for /r %1 %%b in (*.%ext%) do (if %2 equ %%~zb call :CheckDate "%~3" "%%~b")    goto :EOF     :CheckDate    if "%~t1" equ "%~t2" (        pushd "%~dp2"        ren "%~nx2" "%~nx1"        if not exist "%~nx2" (            set /a renfiles+=1            echo Renamed: "%~nx2" To: "%~nx1" >>"%~dp0%RenSSDT.log"        )        popd    )    goto :EOF     endlocal     End of Batch [email protected]  // JScript section // Creates a dialog box that enables the user to select a folder and display it.var title = "Select a folder", rootFolder = 0x11;var shl = new ActiveXObject("Shell.Application");var folder = shl.BrowseForFolder(0, title, 0, rootFolder);WScript.Stdout.WriteLine(folder ? folder.self.path : "");
Log file output:

--- Code: Text ------------------------------ Wed 05/06/2013  23:36:35.97 --------------------------- Renamed: "gyjkhgjkgh.jpg" To: "20012.jpg" Renamed: "51jbbjbjk.jpg" To: "[email protected]"
Wow, this thing's getting huge....it's cracked 2kB in size.

DyNama:
so is it actually checking all 3 criteria, size, date, and checksum?-DyNama (June 04, 2013, 07:57 PM)
--- End quote ---

No - you said it wasn't finding any matches when it used the checksums, so that's not in this version.  It's just size, date and time.

Besides unless I can find a way to get it to work with Delayed Expansion enabled and ! in filenames I can't use the MD5 routine since it relies on Delayed Expansion.
-4wd (June 04, 2013, 08:17 PM)
--- End quote ---

That's okay, that explains how it is so fast!

V7 Added log file and option to display at end, (written to same folder as batch file), it just keeps getting bigger until you delete it
-4wd (June 04, 2013, 08:17 PM)
--- End quote ---

i love logs! unfortunately my 2 runs of RenSSDTv7 did not make a log. i searched everywhere! the path to the batch file is C:\My Stuff\RenSS\RenSSDTv7.cmd―i put "home-made" stuff in it's own folder cuz Win7 doesn't always let me write to Program Files (x86).

DyNama:
i thot maybe the space in the path C:\My Stuff\RenSS\RenSSDTv7.cmd was bothering the log file so i replaced every instance of
%~dp0%RenSSDT.log
--- End quote ---
with
"%~dp0%RenSSDT.log"
--- End quote ---
and voilà! it created the log file and logs every rename! but if
choice /c ny /m "View logfile"
--- End quote ---
is supposed to ask me if i want to view the log, it still doesn't. it echos a "goto" in the CMD window and then closes.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version