date modified = date creation

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
Hurdet
Power Member
Power Member
Posts: 716
Joined: 2003-05-10, 18:02 UTC

date modified = date creation

Post by *Hurdet »

Do it is possible to change in batch the date modified to date creation?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Select files, open attributes window, then use bottom window part (Plugins). You can change any time/date using any other time/date.
Hurdet
Power Member
Power Member
Posts: 716
Joined: 2003-05-10, 18:02 UTC

Post by *Hurdet »

ty
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Here with a CMD Batch.

Utilize "ForFiles myBatch.cmd @file" to execute the batch for every file in folder.


X:\myFolder>ForFiles /M *.txt /c "cmd /c SetModifiedToCreated1.cmd @file"



SetModifiedToCreated1.cmd

Code: Select all

@echo off
REM change date modified to date created
REM use date created as date modified time
REM Get file date created > tmp
REM Set file date modified < tmp


REM USAGE: X:\myFolder>ForFiles /M *.txt /c "cmd /c SetModifiedToCreated1.cmd @file"

SET myfile=%1

REM Touch for Win32, Version 1.0
REM Freeware by Steve P. Miller (stevemil@pobox.com).  Copyright 1997.
REM Visit http://pobox.com/~stevemil for the latest version and other utilities.

REM Get file date created > tmp:
for /f "tokens=2 skip=4" %%A in ('touch.exe /c /v %myfile%') DO @SET Timestamp=%%A

REM Set file date modified < tmp:
touch /m /d %Timestamp% %myfile%

- - -

Instead of ForFiles you can also utilize TCs %L parameter:

Code: Select all

@ECHO OFF

REM Challenge:
REM change date modified to date created
REm use date created as date modified time
REM Get file date created > tmp
REM Set file date modified < tmp


REM TC Button:
REM CMD: this batch
REM Para: %L
SET ListFile=%1


REM needs utility:
REM Touch for Win32, Version 1.0
REM Freeware by Steve P. Miller (stevemil@pobox.com).  Copyright 1997.
REM Visit http://pobox.com/~stevemil for the latest version and other utilities.
        
        
setLocal EnableDelayedExpansion
for /f "delims=" %%F in (%ListFile%) do (
        SET CurrName="%%F"

        REM Get file date created > tmp:
        for /f "tokens=2 skip=4" %%T in ('touch.exe /c /v !CurrName!') DO @SET Timestamp=%%T

        REM Set file date modified < tmp:
        ECHO Set creation date !Timestamp!  as modified date to  !CurrName! 
        touch /m /d !Timestamp! !CurrName! >NUL
        REM Pretty up the output:
        ECHO. & ECHO - - - & ECHO.
)

ECHO All done!
PAUSE



- - -
Edit

My touch /c /v output is as follows. If yours differ, you have to adjust FOR ("tokens=2 skip=4") parameters.

Code: Select all

c:\Temp\BatchTEST>touch /c /v "aaa - Kopie.txt"

Processing: c:\Temp\BatchTEST\aaa - Kopie.txt

aaa - Kopie.txt
   Created:   6/13/2014   4:09:14.803 PM  Friday

c:\Temp\BatchTEST>



.
Post Reply