date modified = date creation
Moderators: Hacker, petermad, Stefan2, white
date modified = date creation
Do it is possible to change in batch the date modified to date creation?
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
- - -
Instead of ForFiles you can also utilize TCs %L parameter:
- - -
Edit
My touch /c /v output is as follows. If yours differ, you have to adjust FOR ("tokens=2 skip=4") parameters.
.
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>
.