CopyDate

Title CopyDate
File Name CopyDate.txt
Description Assign creation and modification date and time of one file (source) to another file (target)
Author Vochomurka
Parameters "%P%N", "%T%M"
Parameter 1: target
Parameter 2: source
(files can be exchanged at the script execution)
Plugins Called file, miscplugin
Icon
Version 1.0
Updated on 16.09.2005
local Create, Modify, Date, Time, Temp, FormDate, FormTime, Mess, Result, i
local mpDlgCaption, mpIcon, mpDlgText

local Source = arg(2)
local Target = arg(1)

for(i = 1; i <= 2; i = i + 1)
	if(file.isfolder(arg(i)) == 1) do
		Mess = "Parameter 1 (source): " ++ arg(1) ++ "\nParameter 2 (target): "
		Mess = Mess ++ arg(2) ++ "\nParameter " ++ i
		Mess = Mess ++ " must be a file rather than a folder!"
		mpDlgCaption = "Error"
		mpIcon = "ERROR"
		mpDlgText = Mess
		Result = MiscPlugin.MessageBox(1, "OK")
		quit
	endif
endfor

@start

Create = file.getdate(Source, "c")
Modify = file.getdate(Source, "m")

Date = select(Create, 8)
Time = select(Create, 7, 14)
Temp = select(Create, 9, 14)

FormDate = formatdate("longdate", Date)
FormTime = formattime("HH:mm:ss", Temp)

Mess = "Source file " ++ Source ++ ":\n\n" ++ "Creation Date && Time:\n" ++ FormDate ++ ", " ++ FormTime

Date = select(Modify, 8)
Time = select(Modify, 7, 14)
Temp = select(Modify, 9, 14)

FormDate = formatdate("longdate", Date)
FormTime = formattime("HH:mm:ss", Temp)

Mess = Mess ++ "\n\nModification Date && Time:\n" ++ FormDate ++ ", " ++ FormTime

Create = file.getdate(Target, "c")
Modify = file.getdate(Target, "m")

Date = select(Create, 8)
Time = select(Create, 7, 14)
Temp = select(Create, 9, 14)

FormDate = formatdate("longdate", Date)
FormTime = formattime("HH:mm:ss", Temp)

Mess = Mess ++ "\n\n\nTarget file " ++ Target ++ ":\n\n" ++ "Creation Date && Time:\n" ++ FormDate ++ ", " ++ FormTime

Date = select(Modify, 8)
Time = select(Modify, 7, 14)
Temp = select(Modify, 9, 14)

FormDate = formatdate("longdate", Date)
FormTime = formattime("HH:mm:ss", Temp)

Mess = Mess ++ "\n\nModification Date && Time:\n" ++ FormDate ++ ", " ++ FormTime ++ "\n\nProceed with copying date from Source to Target?\n(Choose 'Exchange' to exchange Source with Target)"

mpDlgCaption = "Copy Date && Time"
mpIcon = "path_to_icon"
mpDlgText = Mess
Result = MiscPlugin.MessageBox(1, "&Go!", "E&xchange", "&Cancel")

if(Result == "&Go!") do
	Create = file.getdate(Source, "c")
	Date = select(Create, 8)
	Time = select(Create, 9, 14)
	file.setdate(Target, "c", Date, Time)
	Create = file.getdate(Source, "m")
	Date = select(Create, 8)
	Time = select(Create, 9, 14)
	file.setdate(Target, "m", Date, Time)
elseif(Result == "E&xchange") do
	Mess = Source
	Source = Target
	Target = Mess
	jump start
endif

Comments:

Sometimes (for example, after editing a digital photo file) there is a necessity to copy creation and modification date and time of one file (backup copy made before editing) to the file after editing. How to do so with Total Commander?

Then you have to do the same for the "Time" edit box. It's quite boring, isn't it?

Good alternative is to:

In the case of error press the "Exchange" button first. In fact, you can just point both (source & target) files in both panels with no troubling yourself about which of them is a source and which is a target. After reading the detailed information about both files provided by a dialog box you would make a choice whether to press "Go!" at once or exchange files first. The last action can be performed as many times as you hesitate.

If there are many files you want change date/time for, you should use the BatchCopyDate script.


All Scripts Total Commander TotalCmd.net PowerPro