Editing Files Attributes
Moderators: Hacker, petermad, Stefan2, white
Editing Files Attributes
Hi all.
I need to batch-edit the writetime attribute of selected files, adding or subtructing a fixed amount of time (shift), relative to the actual writetime itself.
I found some useful advise in this topic:
http://ghisler.ch/board/viewtopic.php?p=120698
but at the moment I'm stuck to the impossibility to place an expression in the "value" field (well this didn't really surprised me, because I was aware of pushing the field functionality beyond its purpose...).
My try was looking something like this: (adding 3 hours to the timestamp, in this example):
[x] change plugin attribute:
"tc.writetime" = "[=tc.writetime.h+03]"
Can someone please give me an advise on how to obtain this?
Thank you very much.
I need to batch-edit the writetime attribute of selected files, adding or subtructing a fixed amount of time (shift), relative to the actual writetime itself.
I found some useful advise in this topic:
http://ghisler.ch/board/viewtopic.php?p=120698
but at the moment I'm stuck to the impossibility to place an expression in the "value" field (well this didn't really surprised me, because I was aware of pushing the field functionality beyond its purpose...).
My try was looking something like this: (adding 3 hours to the timestamp, in this example):
[x] change plugin attribute:
"tc.writetime" = "[=tc.writetime.h+03]"
Can someone please give me an advise on how to obtain this?
Thank you very much.
What you actual need is AddTime utility. Get it on http://www.totalcmd.net/plugring/addtime_addon.html and put on the toolbar with %L parameter.
Thank you Gral, your suggestion was very useful.
Unfortunately, while fitting perfectly on file attributes, the addon behavior on selected directories is not as needed; Instead of modifying the writetime of the directory itself, the addon modify the writetime of each file contained in it.
I'm checking a way to work this thing out - any additional advise is greatly appreciated, of course.
Unfortunately, while fitting perfectly on file attributes, the addon behavior on selected directories is not as needed; Instead of modifying the writetime of the directory itself, the addon modify the writetime of each file contained in it.
I'm checking a way to work this thing out - any additional advise is greatly appreciated, of course.
BTW, AddTime.ahk:
Roman
Code: Select all
IfLess, 0, 7
Goto, ShowHelp
IfGreater, 0, 9
Goto, ShowHelp
IfEqual, 1, +
Add = 1
Else
IfEqual, 1, -
Add = 0
Else
Goto, ShowHelp
Years = %2%
Months = %3%
Days = %4%
Hours = %5%
Minutes = %6%
Seconds = %7%
RecurseVar = 0
FilePattern = *.*
If %8%
{
IfEqual, 8, r
{
RecurseVar = 1
If %9%
{
FilePattern = %9%
}
}
Else
FilePattern = %8%
}
StringLen, Len, Years
Len := (4 - Len)
Loop, %Len%
Years = 0%Years%
StringLen, Len, Months
Len := (2 - Len)
Loop, %Len%
Months = 0%Months%
StringLen, Len, Days
Len := (2 - Len)
Loop, %Len%
Days = 0%Days%
StringLen, Len, Hours
Len := (2 - Len)
Loop, %Len%
Hours = 0%Hours%
StringLen, Len, Minutes
Len := (2 - Len)
Loop, %Len%
Minutes = 0%Minutes%
StringLen, Len, Seconds
Len := (2 - Len)
Loop, %Len%
Seconds = 0%Seconds%
Loop, %FilePattern%, 1, %RecurseVar%
{
FileGetTime, TimeStamp, %A_LoopFileFullPath%
If Add
EnvAdd, TimeStamp, Years Months Days Hours Minutes Seconds
Else
EnvSub, TimeStamp, Years Months Days Hours Minutes Seconds
FileSetTime, TimeStamp, %A_LoopFileFullPath%
If ErrorLevel
MsgBox, Error: Failed to set time of '%A_LoopFileFullPath%'
}
Return
ShowHelp:
MsgBox,
(
Usage:
%A_ScriptName% <+|-> <years months days hours minutes seconds> [r] [file_mask]
+ or -: + means add time, - means subtract ;-)
years - seconds: Provide a number for each, a 0 for unneeded values
r: Work recursively, ie change the time of all files specified by file_mask in all subdirectories
file_mask: Specify a file mask to use. Default is *.*
Example:
%A_ScriptName% + 0 0 0 2 8 0
Changes the time of all the files in the current directory by + 2 hours, 8 minutes
)
Return
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
I had to correct some things to have the script working (WinXP SP3 + AutoHotkey v1.1.11.01).
At the moment it's working fine on all files and folders present in the selected panel; I still have to:
- 1) Took away Years and Months variables, since the EnvAdd instruction doesn't manage them; Rewrote the EnvAdd code portion to have it properly recognize the "TimeUnit" variables property.
2) Took away digit number control and sign control on command line parameters, since the EnvAdd instruction can handle itself signed variables of different digit length (tried 1 to 3 signed digit variables, Ok).
3) Used the freed 1st parameter (+|-) as parameter to process TimeStamp of Files only, Folders only or both Files and Folders (A|F|D).
Recursive and filemask parameters working fine.
At the moment it's working fine on all files and folders present in the selected panel; I still have to:
- 1) Have it working in the Listbox (actually it doesn't), since I use Alt-F7 to search for files and folders with a given timestamp interval, and then "feed" them to the Listbox for the purpose of Timeshifting them.
2) Have it working ONLY on the file under cursor OR on SELECTED files, not on ALL the files in the panel as now.
Code: Select all
IfLess, 0, 5
Goto, ShowHelp
IfGreater, 0, 7
Goto, ShowHelp
IfEqual, 1, F
Target = 0
Else IfEqual, 1, D
Target = 2
Else IfEqual, 1, A
Target = 1
Else
Goto, ShowHelp
Dn = %2%
Hn = %3%
Mn = %4%
Sn = %5%
RecurseVar = 0
FilePattern = *.*
If %6%
{
IfEqual, 6, R
{
RecurseVar = 1
If %7%
{
FilePattern = %7%
}
}
Else
FilePattern = %6%
}
Loop, %FilePattern%, %Target%, %RecurseVar%
{
FileGetTime, TimeStamp, %A_LoopFileFullPath%
EnvAdd, TimeStamp, Dn, days
EnvAdd, TimeStamp, Hn, hours
EnvAdd, TimeStamp, Mn, minutes
EnvAdd, TimeStamp, Sn, seconds
FileSetTime, TimeStamp, %A_LoopFileFullPath%
If ErrorLevel
MsgBox, Error: Failed to set time of '%A_LoopFileFullPath%'
}
Return
ShowHelp:
MsgBox,
(
Usage:
%A_ScriptName% <F|D|A> <days hours minutes seconds> [R] [file_mask]
F : Process Files only
D : Process Folders only
A : Process both Files and Folders
days - seconds : signed TimeShift values, 0 for unneeded values
R: Work recursively, ie change the time of all files specified by file_mask in all subdirectories
file_mask: Specify a file mask to use. Default is *.*
Example:
%A_ScriptName% A 0 2 -8 0
Shift the timestamp of both Files and Folders in the current directory,
adding 2 hours and subtracting 8 minutes.
)
Return