 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
MichaelH Guest
|
Posted: Wed Mar 02, 2005 3:01 pm Post subject: copy newest file to an other directory |
|
|
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/
|
Posted: Wed Mar 02, 2005 4:34 pm Post subject: |
|
|
| 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 |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Wed Mar 02, 2005 4:45 pm Post subject: |
|
|
Set the flag in filecopy to 1, overwrite. _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Mar 02, 2005 6:45 pm Post subject: |
|
|
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
|
Posted: Wed Jun 14, 2006 4:39 pm Post subject: copy newest file to an other directory |
|
|
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)
|
Posted: Thu Jun 15, 2006 11:46 am Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|