Announcement

Collapse
No announcement yet.

Copy the Most Recent File created.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Copy the Most Recent File created.

    Hi,

    Is there a script that will copy the most recent file created from a folder and paste it into another directory?

    I found this but it doesn't seem to work.


    Code:
    ::Copy Files Made Or Modified Today
    @echo off
    setlocal
    set source=c:\copy
    set dest=c:\paste
    pushd "%source%"
    for %%f in ('dir /b /a-d') do (
        echo "%%~tf" | find "%date%" > nul && copy "%%~ff" "%dest%"
        )
      endlocal & goto :EOF

  • #2
    Re: Copy the Most Recent File created.

    Copy just one file? then you can try,
    Code:
    ::Copy the File that has been modified most recently of all files in the folder
    
    @echo off
    
    set "source=C:\temp"
    set "dest=c:\paste"
    
    pushd "%source%" ||(
       echo.Source does not exist&pause&goto EOF)
    
    for /f "tokens=*" %%f in (
       'dir /A-D /OD /B') Do set "file=%%f"
    
    popd
    
    xcopy /d /i "%source%\%file%" "%dest%\"
    /Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Copy the Most Recent File created.

      Thank you so much Rems!

      Comment

      Working...
      X