BatchCopyDate

Title BatchCopyDate
File Name BatchCopyDate.txt
Description Assign creation and modification date and time of a file in one panel to the file with the same name in the opposite panel
Author Vochomurka
Parameters "%P", "%T"
Parameter 1: directory with files to copy date/time to
Parameter 2: directory with files to copy date/time from
(these directories can be exchanged at the script execution)
Plugins Called file, miscplugin, osd
Icon
Version 1.1
Updated on 16.06.2014

args ToPath, FromPath
local Date, Time, Temp, ToList, ToFiles, FromList, FromFiles, i, j
local One, Other, ToName, FromName
local Counter

local mpDlgText
local mpDlgCaption = "Batch Date & Time Change"
local mpIcon = "QUESTION"

@Start
ToList = file.listfiles(ToPath, 0, 0)
ToFiles = line(ToList, 0)

FromList = file.listfiles(FromPath, 0, 0)
FromFiles = line(FromList, 0)

mpDlgText = "Source path is '" ++ ToPath ++ "' , containing " ++ ToFiles ++ " files."
mpDlgText = mpDlgText ++ "\nTarget path is '" ++ FromPath ++ "' , containing "
mpDlgText = mpDlgText ++ FromFiles ++ " files."
mpDlgText = mpDlgText ++ "\n\nAre you sure to copy date && time from " ++ FromPath
mpDlgText = mpDlgText ++ " to " ++ ToPath
mpDlgText = mpDlgText ++ "?\nPress 'Exchange' to exchange Source <-> Target"

Temp = MiscPlugin.messagebox(1, "&Go!", "E&xchange", "&Cancel")
if(Temp == "&Cancel") do
	quit
elseif(Temp == "E&xchange")
	Temp = ToPath
	ToPath = FromPath
	FromPath = Temp
	jump Start
endif

for(i = 1; i <= ToFiles; i++)
	One = line(ToList, i)
	ToName = file.nametype(One)
	ToName = case("lower", ToName)
	for(j = 1; j <= FromFiles; j++)
		Temp = "Comparing " ++ i ++ " of " ++ ToFiles ++ " with " ++ j
		Temp = Temp ++ " of " ++ FromFiles
		osd.show(Temp, "INFINITE", "30", "Arial", "-1", "255 000 000")
		Other = line(FromList, j)
		FromName = file.nametype(Other)
		FromName = case("lower", FromName)
		if(ToName == FromName) do
			Counter++
			Temp = file.getdate(Other, "c")
			Date = select(Temp, 8)
			Time = select(Temp, 9, 14)
			file.setdate(One, "c", Date, Time)
			Temp = file.getdate(Other, "m")
			Date = select(Temp, 8)
			Time = select(Temp, 9, 14)
			file.setdate(One, "m", Date, Time)
		endif
	endfor
endfor

osd.hide
mpIcon = "D:\Graphics\Icons\User\CopyDate.ico"
if(Counter == 0) do
	mpDlgText = "No equal names found"
else
	mpDlgText = "Time && date is changed for " ++ Counter ++ " of " ++ ToFiles ++ " files"
endif

MiscPlugin.messagebox(1, "&OK")

Comments

Present script uses the same idea as the CopyDate script. But date/time are copied from group of files in path1 to the group of files with the same names in path2. What is that for?

Just one example. After returning from journey you have a lot of digital photos, but they need editing. Unfortunately, most of the graphical editors change creation and/or modification date(s) of files. Why unfortunately? Because one of the advantages of digital photos is that the date/time of the file correspond to those when the photo was taken. Therefore, the problem is to restore date/time from the initial file. If it is only one, the CopyDate script can be used. But if there are some hundreds of them...

Before running the script you have to open the appropriate directories in both Total Commander panels. Default mode is: source panel contains edited files with date/time to be copied to, while target panel contains initial files to copy date/time from. If you have mistaken, the script allows to exchange target <-> source panels, that is, to <-> from directories.

Script informs you about the current stage of its work. If you don't want it to display text, just delete two script lines beginning with the osd. characters.


All Scripts Total Commander TotalCmd.net PowerPro