VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Hi cats,

    please I wonder if is there a way to build a batch that output the last modified .mxf file in a folder

    for example:

    C0001.MXF
    C0002.MXF
    ...
    C0008.MXF is the last

    --> the batch should out C0008.MXF

    thanks
    Quote Quote  
  2. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    https://www.experts-exchange.com/questions/20926359/Finding-the-last-modified-file-thr...S-command.html

    :: ----------EXAMPLE.BAT-----------
    @ECHO OFF
    FOR /F "DELIMS=" %%F IN ('DIR /B /A-D /OD /TW C:\FOLDER\c*.mxf') DO (
    SET FILE=%%F
    )
    ECHO Most recently modified file is:
    ECHO %FILE%
    ECHO %FILE% > X:\OutputPath\Results.txt
    :: ----------EXAMPLE.BAT-----------

    Modify paths,folders for your needs
    Quote Quote  
  3. thanks you, I see that only now. However honestly I need to change my basic request in this way:

    https://forum.videohelp.com/threads/384994-batch-to-return-the-last-item-in-a-txt-file
    Quote Quote  
  4. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Hi, please I have a myfile.txt that contains:

    Code:
    "C0001.MXF" "C0002.MXF" "C0003.MXF" "C0004.MXF" "C0005.MXF" "C0006.MXF" "C0007.MXF"
    Can I isolate only the last item:

    C0007.MXF

    ? thanks
    ------------------------
    You may have to adjust myfile.txt but you can use multiple delimiters:
    https://stackoverflow.com/questions/32690206/delims-more-then-1-character-as-delimiter

    Code:
    @echo off
        setlocal enableextensions disabledelayedexpansion
    
        for /f "delims=" %%a in (myfile.txt) do (
            set "buffer=%%a"
            setlocal enabledelayedexpansion
            (for /f "tokens=1,2,3,4,5,6,7 delims=¬" %%b in ("!buffer:" "=¬!") do (
                endlocal
                echo full line    : [%%a]
                echo first token  : [%%b]
                echo second token : [%%c]
    	    echo third token  : [%%d]
                echo fourth token : [%%e]
                echo fifth token  : [%%f]
    	    echo 6th token    : [%%g]
    	    echo Last token   : [%%h]
            )) || if "!!"=="" endlocal 
        )
    Click image for larger version

Name:	dosscrn.jpg
Views:	393
Size:	33.3 KB
ID:	43093
    Quote Quote  
  5. oh wonderful thanks
    Quote Quote  



Similar Threads

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