Ram Posted December 13, 2007 Share Posted December 13, 2007 (edited) Hi, I have a folder which has many XLS files but I am not sure with the names of file. I would like to move file by file to another folder. This is accordingly to file created time or something like that. For eg: I have two folders - Temp and final. I have 50 files in Temp folder. I would like move one file and do some calculation to it and delete the file. The same I have to move the second file do some callculation and delete it. Moving file should be accoridng to file created time. Is this possible? Oh btw: I am not with the file name that gets stored in temp folder.? How do i go about doing it? Is there a file to find out file created time and move only XLS file accordingly? Or is there any other way to do this? It would be great if I get some help! Awaitng your response! Thanks! Edited December 13, 2007 by Ram Link to comment Share on other sites More sharing options...
smashly Posted December 13, 2007 Share Posted December 13, 2007 Hi, Functions you maybe should look at to accomplish your task, all can be found in AutoIt help file. _FileListToArray() (Found in the User Defined Function Section under File Management) FileGetTime() (Found in Function Reference Section under File, Directory and Disk Management) StringTrimRight() (Found in Function Reference Section under String Management) FileMove() (Found in the User Defined Function Section under File Management) Cheers Link to comment Share on other sites More sharing options...
Ram Posted December 13, 2007 Author Share Posted December 13, 2007 (edited) Hi, Functions you maybe should look at to accomplish your task, all can be found in AutoIt help file. _FileListToArray() (Found in the User Defined Function Section under File Management) FileGetTime() (Found in Function Reference Section under File, Directory and Disk Management) StringTrimRight() (Found in Function Reference Section under String Management) FileMove() (Found in the User Defined Function Section under File Management) Cheers Thanks a lot Smashly...for giving me ideas... Now i have till here and I am sure i am doing something wrong: #Include <File.au3> #Include <Array.au3> While 1 If FileExists("D:\a") Then $FileList=_FileListToArray("D:\Temp") $a = "D:\Temp\" & $FileList[1] FileMove($a, "D:\Final\") Else MsgBox (0,"","No Files\Folders Found.") Sleep (1000) EndIf WEnd I thought this will give me message "No files found found" if the file doesn't exist instead it keeps giving me an error: D:\test.au3 (10) : ==> Subscript used with non-Array variable.: $a = "D:\a\" & $FileList[1] $a = "D:\a\" & $FileList^ ERROR Why would it need to go in to the array first case because the folder is empty? Any help will be appreciated! Thanks! Edited December 13, 2007 by Ram Link to comment Share on other sites More sharing options...
smashly Posted December 13, 2007 Share Posted December 13, 2007 Hi again, try this..#Include <File.au3> $Source = "D:\Temp" $Destination = "D:\Final" If FileExists($Source) Then $FileList = _FileListToArray($Source, "*.xls", 1) ;*.xls files only added to array If Not @error Then For $i = 1 To $FileList[0] FileMove($Source & "\" & $FileList[$i], $Destination & "\" & $FileList[$i], 8) Next Else MsgBox (0,"Error: " & @error, "Look at _FileListToArray() function in AutoIt help file to find what this error means.") EndIf EndIf Cheers Link to comment Share on other sites More sharing options...
Ram Posted December 13, 2007 Author Share Posted December 13, 2007 Hi again, try this..#Include <File.au3> $Source = "D:\Temp" $Destination = "D:\Final" If FileExists($Source) Then $FileList = _FileListToArray($Source, "*.xls", 1) ;*.xls files only added to array If Not @error Then For $i = 1 To $FileList[0] FileMove($Source & "\" & $FileList[$i], $Destination & "\" & $FileList[$i], 8) Next Else MsgBox (0,"Error: " & @error, "Look at _FileListToArray() function in AutoIt help file to find what this error means.") EndIf EndIf Cheers Wow.. Thanks a lot. It worked. I didn't some alternation so that it keep checking for files all the times..~~ Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now