AutoHotkey Community

It is currently May 27th, 2012, 4:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 19th, 2010, 7:13 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
Hi, I have two questions about FileSetTime.

First, let me tell you that I very often take screenshots of certain windows in my computer then I send them via e-mail or host in photoservices like tinypic and photobucket. I already created a HK to let it take the pic, open IrFanView, and paste. I make the adjustments and save. By default, this fresh image goes to the desktop folder.

This means that the last file created on the desktop was the picture itself. So, when I go to the hosting services, I have to browse to the picture, which is a tedious task. But, knowing that it is necessarily the last created file, how to have a hotstring send the path of it, like:
:*:lastimg::C:\...\Destktop\%thelastpic%.jpg

I thought about FileGetTime, but like the own description says...
Code:
Retrieves the datetime stamp of a file or folder.


...means that it is gonna get some file's creation time, but that`s the point: I don't know the filename I'm going to give to the image. Also, getting the creation time of the desktop as a folder is pointless. By consequence I think I need to retrieve all desktop individual files' creation times, check which one is the newest, then return its path. This is what I don't know how to do.


The second question, which creeps me out:
I never know before that AHK was able to modify a file's creation time (FileSetTime). So, at first, this means that false evidence can be forged or planted in one's computer and prove that its been written months ago, something that would be "nice" in a court of law.
OR am I misinformed and this can easily be done without AHK, in Windows itself, with no deep knowledge?

Thanks for the help!

_________________
AHK is perfect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 8:34 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
If you want a list of files by date, look at Loop (files & folders)
http://www.autohotkey.com/docs/commands/LoopFile.htm
Example 4 is by Mod date, but it should be trivial to use created date.

I have not used the FilSetTime command.
However, I have used other programs which were able to change those 3 timestamps. Now that I have WinVista, I see that WinExplorer allows viewing even more timestamps. Besides "Mod, creation and last access", I can see column entries for date acquired, archived, completed, last save, received, released, date sent, date taken (photo?) and date visited.

I can't speak to the level of knowledge required, but surely others can make any changes because the data is just bits and bytes.

Concerning you last saved image, why not establish a system that uses current date AS the filename, 18 characters seems enough.
While you are at it, why not have a txt file that gives a description of the file.

Alternately, just give the new file the next number in a list. For Ahk scripts I have somehing like AK?????.ahk If you have your script doing all the work, why not let the script name the file? In this case, you can save the value of the last generated image in an INI file.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 10:34 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
Thanks for the clarifications about the timestamps!

About the goal I need: no, this doesn't have to get too complicated like that!
But lets see: if I have the current date to be set as the image filename, like
19-2-10__07-33.jpg, what if I need to uipload more than one image (or any kind of file, assuming this can also be used in e-mail attachments)?

Look, this could be easy to do in the first step: the file saving part. For example, I use IrFanView, a very decent image handling program, and then I put the new file on the desktop.

Then, I go to something like bayimg or tinypic, or photobucket, where I have an account. The idea is, when I'm prompted to the file to be uploaded, I don't have the need to browse for it, to avoid the não se trata dey task which is the file navigation.

Or you might have another suggestion for this! :)

_________________
AHK is perfect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 11:11 am 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
If you use unix time it is easy to sort (and have a unique name)and you can always convert to "human time"

Code:
F4::

T = %A_Now%
T -= 1970,s
send,%T%.jpg

return


1266577859.jpg
1266577861.jpg
1266577862.jpg
1266577863.jpg
1266577864.jpg
1266577865.jpg

unless you create more than 1pic a second :)

to go back to human time
Code:
S = 1970
S += T,s
MsgBox YYYYMMDDHH24MISS = %S%



Just played around with it:

Code:
FileList =
ImageDir= E:\testimages\
data=

Loop,%ImageDir%*.jpg
FileList .= A_LoopFileName "`,"
Sort, FileList,R D,

Loop, Parse, FileList,CSV
{
data:=A_LoopField
Break
}
stringtrimright,timedata,data,4
S = 1970
S += timedata,s
FormatTime, time,%s%

MsgBox,4,imagedata=%time%, If you want to copy/paste click yes `n`n %ImageDir%%data%
IfMsgbox yes
clipboard = %ImageDir%%data%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 5:38 pm 
Da Rossa wrote:
and then I put the new file on the desktop.

...wouldn't it be better to create a folder for "new pix", that is only a temp holding place for new pix, until this Hotkey deals with them & after it's done with them it moves them to a Pix folder (or to the Desktop, if you like it full of Pix)...

I skimmed a bit, so I may have missed it...why can't you specify the filename to IrFanView?...but anyway I think a dedicated dir for "new pix" is best, it can handle any amount of new pix, loop over that folder, every file is a new pic to "deal with", don't have to find the newest...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 5:45 pm 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
@ yume

Well, we're getting there!
But this code has some issues...
First, it doesn't actually retrieve the last created jpg file in that directory. (I changed E:\testimages to E:\Desktop). I created some image files and the last one indeed was retrieved when I first executed the code. Then, I grabbed one of the files and copied it to the same folder (the own Destkop itself) and executed again. The previous file again was returned, but not the copy, which was, obviously, first created.

SEcond: what if I'd like to extend this to all filetypes, not just .jpg? I replaced
Code:
Loop,%ImageDir%*.jpg

with
Code:
Loop,%ImageDir%*.*

but I had no luck.

Then, I tried changing the .jpg to .txt. Didn't work well... it retrieved an old file; when I crated a new file just to text, the same previous old file was retrieved again. Why?


Quote:
...wouldn't it be better to create a folder for "new pix", that is only a temp holding place for new pix, until this Hotkey deals with them & after it's done with them it moves them to a Pix folder (or to the Desktop, if you like it full of Pix)...

I skimmed a bit, so I may have missed it...why can't you specify the filename to IrFanView?...but anyway I think a dedicated dir for "new pix" is best, it can handle any amount of new pix, loop over that folder, every file is a new pic to "deal with", don't have to find the newest...


No I don't like the desktop full of pix! :P
Creating a temp specialized dir could be fine, but moving the file afterwards could be chaotic because most of them have know destination:recycle bin and others I can move manually to the right dir.

The idea of it being the desktop is good because
1- the file won't stay for longer there;
2- it is the default save dir for IrFanView and downloaded files from Firefox.

But I'd like, if possible, for this to be broader; could extend to all filetypes; for example: I just typed my resumé in Microsoft Word, and saved it in the desktop. I wanna e-mail my potential employer. Then I open Firefox with the webmail, or even Thunderbird, and, when I attach the file, I don't have to browse for it since I know that it was the last to be created so I would just type the magic hotstring to expand to its path, like E:\Desktop\My Resumé.doc...

_________________
AHK is perfect.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 7:07 pm 
Offline

Joined: February 7th, 2008, 9:48 pm
Posts: 509
If you look at the code you will see that the creation time is of the picture not of the file.The time is coded into the filename so copying the file will not change it.I did it because if i screengrab an image to upload i just want a quick access to the filename without using total commander.


You can try this one if you want ,it uses the filecreation timestamp .It is a modification of the example from the helpfile topic Loop files&folders

Code:
FileList =
ImageDir= E:\testimages\
data=

FileList =
Loop, %imagedir%*.*, 1
    FileList = %FileList%%A_LoopFileTimeCreated%`t%A_LoopFileName%`n
Sort, FileList,R
Loop, parse, FileList, `n
{
    if A_LoopField = 
        continue
    StringSplit, FileItem, A_LoopField, %A_Tab%
    break
}




MsgBox,4,imagedata=%FileItem1%, If you want to copy/paste click yes `n`n %FileItem2%
IfMsgbox yes
clipboard = %ImageDir%%FileItem2%


Last edited by closed on February 20th, 2010, 12:49 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 7:19 pm 
Code:
#SingleInstance force

Dir=%A_Temp%\NewFiles
;//Pattern=*.jpg
Pattern=*
NumRecent=10
return

:*:``newest``::
Gosub, TypeNewestFile
return

F9::Gosub, ListNewestFiles
+F9::Gosub, CreateTestFiles

UpdateNewestFiles:
Files=
newest=
Loop, %Dir%\%Pattern%
{
   ;//Files.="`n" A_LoopFileTimeCreated "`t" A_LoopFileName
   Files.="`n" A_LoopFileTimeCreated "`t" A_LoopFileLongPath
}

Files:=RegExReplace(Files, "^`n|`n$")
Sort, Files, R

;// *** HELP *** Can you use L#/R# with InStr()?
;//Files:=SubStr(Files, Files, InStr(Files, "`n", "", "L10"))
StringGetPos, pos, Files, `n, L%NumRecent%
if (errorlevel=0) {
   StringLeft, Files, Files, %pos%
}

Loop, Parse, Files, `n, `r
{
   Loop, Parse, A_LoopField, "`t"
   {
      if (A_Index=2) {
         newest:=A_LoopField
      }
   }
   break
}
return

TypeNewestFile:
Gosub, UpdateNewestFiles
SendInput, {Raw}%newest%
return

ListNewestFiles:
Gosub, UpdateNewestFiles
msgbox,64, ,
(LTrim
   dir(%Dir%)

   newest(%newest%)

   Newest Files (max %NumRecent%)...
   ---
   %Files%
   ---
)
return

CreateTestFiles:
if (!FileExist(Dir)) {
   msgbox, 33, , Directory don't exist...`n`n%dir%`n`nCreate?
   IfMsgBox, OK
      FileCreateDir, %Dir%
   Else return
}
Loop, 19 {
   file=%Dir%\%A_Index%
   if (!FileExist(file)) {
      FileAppend, , %file%
      Sleep, 19
   }
   ts:="201001" SubStr("0" A_Index, -1, 2) "191919"
   FileSetTime, %ts%, %file%, C
   FileSetTime, %ts%, %file%, M
   ;//msgbox, e(%errorlevel%) (%file%) (%A_Index%) (%ts%)
}
return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 69 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