AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

copy newest file to an other directory

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
MichaelH
Guest





PostPosted: Wed Mar 02, 2005 3:01 pm    Post subject: copy newest file to an other directory Reply with quote

Sorry but I cant figure it out:
I want to copy the latest file in a directory to an other directory
but I only get the oldest file. Whats wrong?
Thank you very much for your help
MIchael
Code:

FileList =
Loop, %var_ntlogs_Path%\*.log, 1 
FileList = %FileList%%A_LoopFileTimeModified%`t%A_LoopFileName%`n
Sort, FileList, R ; Sort by date reverse.
Loop, parse, FileList, `n
{
   if A_LoopField =  ; Omit the last linefeed (blank item) at the end of the list.
      continue
   StringSplit, var_FileItem, A_LoopField, %A_Tab%  ; Split into two parts at the tab char.
}
filecopy, %var_ntlogs_Path%\%var_FileItem%, %var_log_path%\%var_Dateiname%_%var_Datetoday%.log

Back to top
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Wed Mar 02, 2005 4:34 pm    Post subject: Reply with quote

AutoHotkey Planned Features wrote:
New command FileGet/Set or FileGetProperties to retrieve and set things from a file's property sheet (title, author, permissions, etc.)

I'm not sure but probabily this soon to come feature might retrieve date-specific data so things can be done like you said.
_________________

Back to top
View user's profile Send private message Visit poster's website
ILL.1



Joined: 29 Sep 2004
Posts: 84

PostPosted: Wed Mar 02, 2005 4:45 pm    Post subject: Reply with quote

Set the flag in filecopy to 1, overwrite.
_________________
===============
----------ILL.1-----------
===============
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Mar 02, 2005 6:45 pm    Post subject: Reply with quote

strange but I got after a short break:
Code:

FileList =
Loop, %var_ntlogs_Path%\*.log, 1  ;
FileList = %FileList%%A_LoopFileTimeModified%`t%A_LoopFileName%`n
Sort, FileList, ; Sort by date
Loop, parse, FileList, `n
{
   if A_LoopField =  ; Omit the last linefeed (blank item) at the end of the list.
      continue
   StringSplit, var_FileItem, A_LoopField, %A_Tab%  ; Split into two parts at the tab char.
}
filecopy, %var_ntlogs_Path%\%var_FileItem2%, %var_log_path%\%var_Dateiname%_%var_Datetoday%.log

Back to top
Floriooaquarius
Guest





PostPosted: Wed Jun 14, 2006 4:39 pm    Post subject: copy newest file to an other directory Reply with quote

I also want to copy the latest file in a directory to an other directory, and I tried this script.
But I get all the files copied. Whats wrong?

Code:
var_ntlogs_Path = I:\CanoScan\_Q_0106   ; Example folder
FileList =

Loop, %var_ntlogs_Path%\*.*, 1
FileList = %FileList%%A_LoopFileTimeModified%`t%A_LoopFileName%`n
Sort, FileList, R ; Sort by date reverse.

Loop, parse, FileList, `n
{
   if A_LoopField =  ; Omit the last linefeed (blank item) at the end of the list.
      continue
   StringSplit, var_FileItem, A_LoopField, %A_Tab%  ; Split into two parts at the tab char.
}

filecopy, %var_ntlogs_Path%\%var_FileItem%, I:\CanoScan\_DTV\%var_FileItem%


Thank you very much for your help.
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Jun 15, 2006 11:46 am    Post subject: Reply with quote

A simplier way:
Code:
newestTime = 19000101000000
newestFile =
Loop E:\Archives\*
{
   If (A_LoopFileTimeModified > newestTime)
   {
      newestTime := A_LoopFileTimeModified
      newestFile := A_LoopFileLongPath
   }
}
MsgBox %newestTime% -> %newestFile%
Put the right path, replace the MsgBox by the right FileCopy, and it should (may) work.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group