Windows 10: Batch: change target directory date after xcopy


  1. Posts : 354
    Windows 10 home 1709/16299.431
       17 Jan 2018 #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 ComputerSystem Spec

  2.    17 Jan 2018 #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 ComputerSystem Spec


  3. Posts : 354
    Windows 10 home 1709/16299.431
    Thread Starter
       18 Jan 2018 #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 ComputerSystem Spec

  4.    18 Jan 2018 #4

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

    Click image for larger version. 

Name:	image.png 
Views:	12 
Size:	8.6 KB 
ID:	173145

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

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

    Click image for larger version. 

Name:	image.png 
Views:	12 
Size:	8.8 KB 
ID:	173149

    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 ComputerSystem Spec


  5. Posts : 354
    Windows 10 home 1709/16299.431
    Thread Starter
       18 Jan 2018 #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 ComputerSystem Spec


 

Related Threads
How can I add to this batch command to include the date: xcopy C:\all\* Z:\Allbak\* /E /Y /C I'd like the resulting file to be named "Z:\Allbak171129" (yr mo day). The plan is to set up a task schedule to run the batch file every week. I...
hi, i want to disable the change time and date in windows ten using batch file, i am using this script to show and hide hidden file @echo off REG ADD "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /V Hidden /T REG_DWORD /D...
Read more: Release Date for Arris DOCSIS 3.1 Modem a Moving Target | Multichannel
How to Change Open Target of Network System Icon in Windows 10 By default in Windows 10, when you click/tap on the Network system icon from the taskbar notification area, it will open to new network fly-out UX for quick access to your network...
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 20:34.
Find Us