Batch: change target directory date after xcopy


  1. Posts : 481
    Windows 10 pro 1903 1862.145
       #1

    Batch: change target directory date after xcopy


    I use this command to make a weekly back up my personal files:
    Code:
    xcopy C:\all\* Z:\Allbak\* /C /D /E /I /W /Y
    Works fine but how can I change the date attribute of the Allbak directory to the current date?
      My Computer


  2. Posts : 809
    Win10
       #2

    XCOPY (and ROBOCOPY) don't seem to have any way to update the timestamp to the current time.

    You'll have to use another utility like BulkFileChanger: Change date/time/attributes of multiple files , which can be used from the command prompt as well as the GUI.

    Edit: Sorry, I think I misread the OP. Do you just want to change the modified date of the Allbak\ folder but leave the timestamps of the files the same? If so, then I don't believe BulkFileChanger will work. If you have access to the Unix "touch" command (e.g. through Cygwin or MSYS) then that's the simplest way.
    Last edited by PolarNettles; 17 Jan 2018 at 22:09.
      My Computer


  3. Posts : 481
    Windows 10 pro 1903 1862.145
    Thread Starter
       #3

    Yes, I want to re-date the backup directory only, not the contents. Most backup programs do this with incremental backups so I hoped I could find a way.
      My Computer


  4. Posts : 809
    Win10
       #4

    If you don't mind installing something, touch.exe is part of Cygwin coreutils.

    Batch: change target directory date after xcopy-image.png

    Otherwise, if you can move to PowerShell then you can also do:

    (Get-Item -Path $folder).LastWriteTime = (Get-Date)

    Batch: change target directory date after xcopy-image.png

    Edit: You can also call the PowerShell command from CMD like:
    Code:
    powershell -Command "(Get-Item -Path c:\temp).LastWriteTime = (Get-Date)"
    Last edited by PolarNettles; 18 Jan 2018 at 10:59.
      My Computer


  5. Posts : 481
    Windows 10 pro 1903 1862.145
    Thread Starter
       #5

    Thanks for the suggestions. I found a program, Attribute Changer which inserts options to the context menu and works quite well. Not automatic but easy and quick. Download at www dot petges dot lu, which is the author's home page. (can't insert verbatim address because Windows automatically switches it to a non-download site.)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:42.
Find Us




Windows 10 Forums