VideoHelp Forum
+ Reply to Thread
Results 1 to 2 of 2
Thread
  1. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    Hi, back again.

    I made up a small util, "updater.bat" that searches through a selected topmost folder and all sub-folders.
    The purpose is to update any files found in the searched folders that matches the "input file" to "Updater", if they are older.
    I have a need for this and the util works fine for my purpose.

    I have a counter that counts the number of folders searched, I display this in the TITLE bar of the CMD window, very small hit on processing time.

    Ideally I would like to have the option to use a second counter !_FILES_FOUND! that would count the number of files matching the "input file" in all of the folders.

    This wouldn't indicate how many were updated, thats probably not possible, but at least it would be nice to know how many there were.

    I'm not sure how to do this, I tried the line below but ( IF EXIST %~n1%~x1 SET /A _FILE_FOUND+=1 ) it never goes above 0.

    Thanks in advance.

    Meant to say, the !_FOLDERS_TO_PROCESS! is a variable representing for example D:\Photos\*.*
    %~f1 is the input file, dragged and dropped.


    @echo off
    cls
    Setlocal EnableDelayedExpansion

    SET /A _COUNTER=0
    SET /A _FILE_FOUND=0
    for /f "tokens=*" %%G in ('DIR /b /s /a:d "!_FOLDERS_TO_PROCESS!"') DO (
    xcopy /d /u /y /v /q "%~f1" "%%G\">nul
    SET /A _COUNTER+=1
    IF EXIST %~n1%~x1 SET /A _FILE_FOUND+=1
    TITLE Updater. Folders searched = [ !_COUNTER! ]. Folders to process = [ !_FOLDERS_TO_PROCESS! ]. File to replace = [ %~n1%~x1 ].
    )
    Quote Quote  
  2. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    Found it ...

    IF exist "%%G\%~n1%~x1" SET /A _FILES_FOUND+=1
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!