SetAttrib date to 'Current' in a single click?
Moderators: white, Hacker, petermad, Stefan2
SetAttrib date to 'Current' in a single click?
please excuse what i'm sure is a noobie question but how would i do this? i know how to set up a button to trigger cm_SetAttrib but it's not obvious how i would tell it to automatically do the "Change Date/Time" to "Current" and go do it. of course the idea is that i just want to point and shoot, not have to deal with the dialog box.
the goal of course is to do like what unix's 'touch' command does by default, namely just update the timestamp of the file to the computer's current date and time, whatever that happens to be. (see touch (Unix) - Wikipedia, the free encyclopedia for reference).
the goal of course is to do like what unix's 'touch' command does by default, namely just update the timestamp of the file to the computer's current date and time, whatever that happens to be. (see touch (Unix) - Wikipedia, the free encyclopedia for reference).
You can get a Windows version of touch here: http://sourceforge.net/projects/unxutils
Then create a button with %P%N
Then create a button with %P%N
You may use simple BAT file:
Write full path to touch.exe, add batch file to buttonbar, set "%WL" as button parameter. Batch will call touch for every selected item in panel.
Code: Select all
@echo off
if -%1==- echo Parameters: "%%WL"&pause &goto :EOF
if -%1==-go goto do_work
for /f "usebackq delims=" %%f in (`type %1`) do call %0 go "%%f" %2
pause
goto :EOF
:do_work
touch.exe %2
Last edited by MVV on 2011-06-20, 17:57 UTC, edited 2 times in total.
exactly what i'm looking for too. sounds like maybe a script is what's required here. anyone got such a thing? for AHK would be ideal, imo.tuska wrote:Does anyone know a solution in which several files could be marked and attributes will changed with one click to current date/time?
... or the one MVV just posted sounds good too (came in as i was typing my post).
Thanks a lot MVV!
works very good - I have only one litte additional question: The batchfile calls the DOS-Box and at the end the DOS-window does not close automatically.
Do you see any possibility to solve this problem- but I don't want you to take too much time on this problem.
I am very happy with your batchfile - thanks again.
works very good - I have only one litte additional question: The batchfile calls the DOS-Box and at the end the DOS-window does not close automatically.
Do you see any possibility to solve this problem- but I don't want you to take too much time on this problem.
I am very happy with your batchfile - thanks again.
Gruß,
Karl
Karl
You may try following command:
Maybe cmd will execute batch itself insted of calling DOSBox, I can't check it since I've never associated DOSBox with batch files.
Code: Select all
Command: cmd.exe /c Full\Path\To\Bat\File.bat
Parameters: "%WL"
fwiw i managed to cobble together an AHK script to do what i wanted, thought it might be of use to others so here it is:
no claims to originality or wonderfulness are made or implied: i borrowed freely from others and am a noobie AHK scripter so it is what it is. improvements and/or recommendations are most welcome.
Code: Select all
; Touch (default) ala UNIX
; script is designed to be called from TotalCommander where the files and/or
; folders to be Touch-ed are sent in as a (temporary) list file .. script
; assumes that each entry in the list is a full path, IOW %L is used in
; TotalCommander's "Parameters" box.
Loop, Read, %1%
{
nextFileOrDir = %A_LoopReadLine%
FileGetAttrib, nextAttributes, %nextFileOrDir%
IfInString, nextAttributes, D
{
; folder (directory) entries in the list
; come to us with a trailing slash, need to
; trim that before we proceed.
StringTrimRight, nextFileOrDir, nextFileOrDir, 1
}
FileSetTime , A_Now, %nextFileOrDir%, M
}
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
Try this:hooly wrote:fwiw i managed to cobble together an AHK script to do what i wanted, thought it might be of use to others so here it is:
...
no claims to originality or wonderfulness are made or implied: i borrowed freely from others and am a noobie AHK scripter so it is what it is. improvements and/or recommendations are most welcome.
Code: Select all
#NoEnv
curTime:=A_Now
Loop, Read, %1%
FileSetTime, %curTime%, % (SubStr(A_LoopReadLIne,0) == "" ? SubStr(A_LoopReadLine,1,-1) : A_LoopReadLine), M
No variable assignments during the loop, we just use A_LoopReadLine. Also no need to check if it is a directory and store the result, just check if the last character of A_LoopReadLine is equal to "", and if so, strip it with SubStr.
Shorthand if/else above.
---> (IF SOMETHING) ? THEN DO THIS : ELSE DO THIS
Note: You should always add #NoEnv to scripts. As well it wouldn't hurt to add these three, which are the default lines AHK will generate if you use it to launch a non-existant script:
Code: Select all
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%