Change date relative to existing file date minus 1 year?
Moderators: white, Hacker, petermad, Stefan2
Change date relative to existing file date minus 1 year?
Hi,
is it possible to change the date/time of files relative to their existing date/time?
E.g., the selected files have a date of 2016-12-12 and 2017-03-01 and I want to change the filedates back a year so that the new dates would be 2015-12-12 and 2016-03-01.
Or (maybe more common) the time needs to be changed by a certain amount, e.g. if a camera was on a wrong setting.
With the "Change Attributes" dialogue, it only seems possible to set a fixed date, not a relative one.
is it possible to change the date/time of files relative to their existing date/time?
E.g., the selected files have a date of 2016-12-12 and 2017-03-01 and I want to change the filedates back a year so that the new dates would be 2015-12-12 and 2016-03-01.
Or (maybe more common) the time needs to be changed by a certain amount, e.g. if a camera was on a wrong setting.
With the "Change Attributes" dialogue, it only seems possible to set a fixed date, not a relative one.
PowerShell: ForEachFileDo_TIMESTAMP.ps1 Adjust add min year
Or use PowerShell
Pure PowerShell syntax:
- - -
Here is a whole script to use with Total Commander.
- save the code to TC folder as "ForEachFileDo_TIMESTAMP.ps1"
- add a button
Cmd = Powershell -NoProfile -NoExit -ExecutionPolicy Unrestricted "%COMMANDER_PATH%\ForEachFileDo_TIMESTAMP.ps1"
Param="%L"
[X] Run minimized
Select all files and execute this script. Done.
- - -
A very simple script:
- - -
Full script:
HTH?
Pure PowerShell syntax:
Code: Select all
GCI | ForEach{ $_.LastWriteTime = ($_.LastWriteTime).AddYears(-1) }
Here is a whole script to use with Total Commander.
- save the code to TC folder as "ForEachFileDo_TIMESTAMP.ps1"
- add a button
Cmd = Powershell -NoProfile -NoExit -ExecutionPolicy Unrestricted "%COMMANDER_PATH%\ForEachFileDo_TIMESTAMP.ps1"
Param="%L"
[X] Run minimized
Select all files and execute this script. Done.
- - -
A very simple script:
Code: Select all
# the
TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime=($F.LastWriteTime).AddYears(-1)}
- - -
Full script:
Code: Select all
# PowerShell Script for Total Commander
# Stefan, 14. March 2017
# http://ghisler.ch/board/viewtopic.php?t=47504
# Adjust timestamp of all selected files
#
# Example:
# FROM:
# 24.12.2001
# TO:
# 24.12.2000
#
# Usage:
# Create TC button
# Cmd=Powershell -NoProfile -NoExit -ExecutionPolicy Unrestricted "%COMMANDER_PATH%\ForEachFileDo_TIMESTAMP.ps1"
# Param="%L"
# [X] Run minimized
#
# Tip: remove '-NoExit' to let the console window close after work.
#
# Select all files and execute this script. Done.
#
#
# ==============================================================================
# // The script
# // Check arguments:
If ($Args.Count -eq 0) { "Please use '%L' as TCs parameter. Also select one or more files first. Script quits here."; return}
# //DEBUG:
# Notepad $Args[0]
# TYPE $Args[0]
# //Prompt the user:
$a = new-object -comobject wscript.shell
$b = $a.popup("Continue changing timestamp? (Inspect script first)",0,"Change Timestamp",1)
if ($b -eq 2){
# Write-Host "You pressed Cancel. Script quits here.`n`n`nPress any key to close..."
# $x = $host.UI.RawUI.ReadKey()
Return
}
# //Do the WORK:
TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime=($F.LastWriteTime).AddYears(-1)}
# -----------------------------------------------------------------
# // some alternatives:
# CreationTime
# LastWriteTime
# LastAccessTime
# AddDays
# AddHours
# AddMilliseconds
# AddMinutes
# AddMonths
# AddSeconds
# AddTicks
# AddYears
# Usage:
# AddYears(2) # add plus two years
# AddYears(-4) # extract minus four years
# -----------------------------------------------------------------
# // or: adjust days and hours and more at the same time
# $MyTimeStamp = New-TimeSpan -Days 1 -Hours 2 -Minutes 30
# TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime=($F.LastWriteTime) + $MyTimeStamp}
# -----------------------------------------------------------------
# // or: set time only
#TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime= "07:55:56"}
# -----------------------------------------------------------------
# // or: set whole new date (MONTH.DAY.YEAR format depends on your system settings)
# Suppose today is August 31, 2007. In the US, we’d list the date like this: 8/31/2007, the format being month/day/year.
# In a very large portion of the world, however, that same date is listed like this: 31/8/2007, the format being day/month/year.
# https://technet.microsoft.com/en-us/library/ee692801.aspx
# TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime= "12.24.2005 07:07:34"}
# First of April at midnight:
# TYPE $Args[0] | ForEach{$F=(Get-Item($_));$F.LastWriteTime= "4.1.2005 00:00:00"}
# -----------------------------------------------------------------
# Pure PowerShell syntax:
# GCI | ForEach{ $_.LastWriteTime = ($_.LastWriteTime).AddYears(-1) }
# -----------------------------------------------------------------
# Create TC button
# Cmd=Powershell -NoProfile -NoExit -ExecutionPolicy Unrestricted "%COMMANDER_PATH%\ForEachFileDo_TIMESTAMP.ps1"
# Param="%L"
# [X] Run minimized
REM TOTALCMD#BAR#DATA
REM Powershell -NoProfile -NoExit -ExecutionPolicy Unrestricted %COMMANDER_PATH%\TOOLs\CMDs\ForEachFileDo_TIMESTAMP.ps1
REM "%L"
REM C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe,1
REM ForEachFileDo_TIMESTAMP.ps1
REM
REM 1
REM -1
# -----------------------------------------------------------------
HTH?
Or Add-ons
Or use the add-ons provided by Hacker, a regular here.
See:
ReDate or AddTime on this page:
http://www.ghisler.com/tools.htm
See:
ReDate or AddTime on this page:
http://www.ghisler.com/tools.htm
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
Re: Or Add-ons
Make sure you update to the latest version of Redate, 1.1.2 - March 2013.Phred wrote:Or use the add-ons provided by Hacker, a regular here.
See:
ReDate or AddTime on this page:
http://www.ghisler.com/tools.htm
Earlier versions tend to lose themselves: 30th February, for example.
PS Roman, thanks for enlarging Redate's window, but it's a bit large and off-screen, isn't it? And you don't remember my resize, nor placement. :(
PPS AddTime's fairly tiny on todays screens, don't you think? And squidgy little spinners..? :)
Last, Redate: you don't correctly remember the old dates. :|
But thanks.
Re-dating Files
Anyone?
'Changing the dates of a set of files, incrementing dates/times by relative amounts.'
I recently redated a set of podcast files, giving each a date one week apart, starting from the date the first one was broadcast on.
Windows Photo Gallery can change the date/times of a set of photos/videos but only on a sliding basis, en mass. A selected group can be re-dated by a certain amount - but not each individually wrt each other.
Hacker's Redater does this; it's just very basic and and doesn't have a likable VMU.
Visual Method of Use (GUI).
'Changing the dates of a set of files, incrementing dates/times by relative amounts.'
I recently redated a set of podcast files, giving each a date one week apart, starting from the date the first one was broadcast on.
Windows Photo Gallery can change the date/times of a set of photos/videos but only on a sliding basis, en mass. A selected group can be re-dated by a certain amount - but not each individually wrt each other.
Hacker's Redater does this; it's just very basic and and doesn't have a likable VMU.
Visual Method of Use (GUI).
Regards, PhredE
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
Licence holder since 1999
Awaiting a $D donors-token for the title-bar so we can display that we have donated further.
See also
NewFileTime 2.99
http://www.softwareok.com/?seite=Microsoft/NewFileTime
NewTime increments or decremants only the file date relative to the file's own date by a fixed number of days.
Bulk Rename Utility 3.0.0.1
http://www.bulkrenameutility.co.uk/Main_Intro.php
The section on Changing File Timestamps
Bulk Rename Utility increments or decrements the file date, hours, minutes and seconds relative to the file's own timestamp by a fixed number of days, hours, minutes or seconds.
BulkFileChanger v1.51
http://www.nirsoft.net/utils/bulk_file_changer.html
Bulk File Changer increments and decrements the file date, hours, minutes and seconds relative to the file's own timestamp or a reference date by a fixed amount or a sequential amount of years, months, days, hours, minutes or seconds.
NewFileTime 2.99
http://www.softwareok.com/?seite=Microsoft/NewFileTime
NewTime increments or decremants only the file date relative to the file's own date by a fixed number of days.
Bulk Rename Utility 3.0.0.1
http://www.bulkrenameutility.co.uk/Main_Intro.php
The section on Changing File Timestamps
Bulk Rename Utility increments or decrements the file date, hours, minutes and seconds relative to the file's own timestamp by a fixed number of days, hours, minutes or seconds.
BulkFileChanger v1.51
http://www.nirsoft.net/utils/bulk_file_changer.html
Bulk File Changer increments and decrements the file date, hours, minutes and seconds relative to the file's own timestamp or a reference date by a fixed amount or a sequential amount of years, months, days, hours, minutes or seconds.
License #1945
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64
Windows 10 Pro x64
Version 22H2 (OS Build 19045.3930)
TC 11.00 x64 and x86, Everything 1.5.0.1366a x64, QAP 11.6.3.1 x64