web analytics

Move file and add timestamp to filename using DOS command script

Options

davegate 143 - 921
@2020-01-20 13:27:33

The following DOS command script will move a file to different folder and add timestamp to the new filename at same time:

    @echo off
    for /f %%a in ('powershell -Command "Get-Date -format yyyy_MM_dd__HH_mm_ss"') do set datetime=%%a

    rem echo copying file

    move "c:\temp\test.txt" "c:\temp\archive\test-%datetime%.txt"

    rem echo done

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com