AutoHotkey Community

It is currently May 27th, 2012, 10:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: November 29th, 2006, 9:04 am 
this little script lets you select a drive/folder and sets the "modified" timestamp of every file and folder in it to the value of the "created" timestamp (NTFS only, obviously).
don't ask me why one would do this, I had to do it it ... :roll:

Code:
;=======================================================================
; AutoHotKey script: SetModToCrea.ahk (V1.0 28.11.06)
;
; set "modified" timestamp of dirs/files to same value as "created"
; for a whole dir tree
;
; use script or parts of it as you like but at your own risk
;
; andreas lang, conTEXT AG, Zurich, Switzerland
;=======================================================================

#SingleInstance ignore               ; don't start script more than once

n = 0                                               ; files/dirs counter

FileSelectFolder, dir, *C:\, 0           ; don't allow making new folder
if ErrorLevel or dir =
{
  msgBox no folder selected. exit!
  exit
}

StringRight, lastDirChar, dir, 1                ; fetch last char of dir
If lastDirChar = \
{
                                ; root dir! don't try changing timestamp
  StringTrimRight, dir, dir, 1                 ; chop trailing backslash
}
Else                                         ; touch selected dir itself
{
  FileGetTime, dirCreaDate,   %dir%, C
  FileSetTime, %dirCreaDate%, %dir%, M, 1, 0
  ++n
}

Loop, %dir%\*.*, 1, 1            ; recursive loop over files AND folders
{
                                       ; files AND folders, no recursion
  FileSetTime, %A_LoopFileTimeCreated%, %A_LoopFileLongPath%, M, 1, 0
  ++n
}

msgBox MODIFIED to CREATED timestamp set for %n% dirs/files.

exit

;=======================================================================


Report this post
Top
  
Reply with quote  
PostPosted: February 1st, 2008, 8:02 am 
same as above but the other way round:

Code:
;=======================================================================
; AutoHotKey script: SetCreaToMod.ahk (V1.00 01.02.08)
;
; set "created" timestamp of dirs/files to same value as "modified"
; for a whole dir tree
;
; use script or parts of it as you like but at your own risk
;
; andreas lang, conTEXT AG, Zurich, Switzerland
;=======================================================================

#SingleInstance ignore               ; don't start script more than once

n = 0                                               ; files/dirs counter

FileSelectFolder, dir, *C:\, 0           ; don't allow making new folder
if ErrorLevel or dir =
{
  msgBox no folder selected. exit!
  exit
}

StringRight, lastDirChar, dir, 1                ; fetch last char of dir
If lastDirChar = \
{
                                ; root dir! don't try changing timestamp
  StringTrimRight, dir, dir, 1                 ; chop trailing backslash
}
Else                                         ; touch selected dir itself
{
  FileGetTime, dirModiDate,   %dir%, M
  FileSetTime, %dirModiDate%, %dir%, C, 1, 0
  ++n
}

Loop, %dir%\*.*, 1, 1            ; recursive loop over files AND folders
{
                                       ; files AND folders, no recursion
  FileSetTime, %A_LoopFileTimeModified%, %A_LoopFileLongPath%, C, 1, 0
  ++n
}

msgBox CREATED = MODIFIED timestamp set for %n% dirs/files.

exit

;=======================================================================


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 50 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group