Jump to content

Ravel

Active Members
  • Posts

    159
  • Joined

  • Last visited

Everything posted by Ravel

  1. Geo... were you still lookin over this?
  2. Nope not one file was copied.
  3. hmm... i just attempted to use it and i got an error stating that it is unable to copy the file? what does that mean? --------------------------- File Error --------------------------- Unable to Copy The File C:\Users\webbdam\Documents\AutoIt\Scripts\Test\POWER OUT USING SPECAN.doc --------------------------- OK ---------------------------
  4. k here is what I found... --------------------------- ERROR TEST --------------------------- review --------------------------- OK --------------------------- ;------------------------------- >"C:\Users\webbdam\Documents\AutoIt\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\webbdam\Documents\AutoIt\Scripts\filereview.au3" C:\Users\webbdam\Documents\AutoIt\Scripts\filereview.au3 (36) : ==> Subscript used with non-Array variable.: $iCreated = $aCreated[0] & $aCreated[1] & $aCreated[2] $iCreated = $aCreated^ ERROR >Exit code: 1 Time: 2.244 ;------------------------------- Full Code $sFldr = "C:\Users\webbdam\Documents\AutoIt\Scripts\Test\" $sFldr2 = "C:\Users\webbdam\Documents\AutoIt\Scripts\Test\review\" $sMovDate = 20090107 -1 $iMoved = _FileMoveByDate($sFldr, $sFldr2, "*", $sMovDate, 1, 0) If NOT @Error Then MsgBox(0, "Finished", $iMoved & " files were moved or copied") If $iMoved Then ShellExecute($sFldr2) Else MsgBox(0, "Error", "The error returned was " & @Error) EndIf ; Func _FileMoveByDate($sPath, $sNewPath, $sPattern = "*", $iDate = -1, $iDateFlag = 0, $iMove = 1, $iOverWrite = 1) Local $sHold, $aCreated, $iCreated, $iCount = 0 If StringRight($sPath, 1) <> "\" Then $sPath &= "\" If NOT FileExists($sPath) Then Return SetError(2) If StringRight($sNewPath, 1) <> "\" Then $sNewPath &= "\" If $iDateFlag > 2 OR $iDateFlag < 0 Then $iDateFlag = 1 If NOT FileExists($sNewPath) Then If NOT DirCreate($sNewPath) Then Return SetError(3) EndIf If $iDate = -1 Then $iDate = @Year & @Mon & @mDay $sFile = FileFindFirstFile($sPath & $sPattern) If NOT @Error Then If NOT FileExists($sNewPath) Then DirCreate($sNewPath) If $iOverWrite <> 1 Then $iOverWrite = 0 While 1 $sHold = FileFindNextFile($sFile) If @Error Then ExitLoop If StringInStr(FileGetAttrib($sHold), "D") Then ContinueLoop $aCreated = FileGetTime($sHold, $iDateFlag);; Might be better to use the 0 (modified) flag here If NOT IsArray($aCreated) Then MsgBox(4096, "ERROR TEST", $sHold & @CRLF & @CRLF & FileGetAttrib($sHold)) $iCreated = $aCreated[0] & $aCreated[1] & $aCreated[2] If $iCreated >= $iDate Then If $iMove = 1 Then If NOT FileMove($sPath & $sHold, $sNewPath & $sHold, $iOverWrite) Then MsgBox(4096, "File Error", "Unable to Move The File " & $sHold) ContinueLoop EndIf Else If NOT FileCopy($sPath & $sHold, $sNewPath & $sHold, $iOverWrite) Then MsgBox(4096, "File Error", "Unable to Copy The File " & $sHold) ContinueLoop EndIf EndIf $iCount += 1 EndIf Wend Else Return SetError(1) EndIf Return $iCount EndFunc;<==> _FileMoveByDate() ; I'm still getting that error... Pertaining to the version, I am running it directly from scite (i cant install autoit on gov't pc) but the scite version is: 1.71, it came from the auto it package: 3.2.8.1. The files aren't all the same (PDF, TXT, DOC, DOCX). Do you think that the problem could be that I couldn't install autoit? I mean I can use the exe's such as the window info exe, scite, and any exe's built on a pc that has the auto it installed.
  5. --------------------------- ERROR TEST --------------------------- review --------------------------- OK --------------------------- Thats what you were looking for right?
  6. Ok. Cool. I am not sure if there is something that I need to do, or if there is something that you are going to check. Is there a way to have it run regardless even if some of the data is incorrect? Or what do i need to ensure that I put in the script to make sure that it will pass? Is that the date? Do I need to ensure that there are files in the folder that match the date that I am searching for to keep it from failing?
  7. I am not sure what you are referring to. Created since jan 6 2009? which files? It fails when I run the script. When I do the syntax check in scite it passes. In that code above I included Filex.au3 in the script (it was failing before I included filex.au3), but it did not solve the problem. here is the error:
  8. Im still getting that same error mentioned above, I must be doing something wrong. here is the code that I am using: #include <Filex.au3> $sFldr = "C:\Users\webbdam\Documents\AutoIt\Scripts\Test" $sFldr2 = "C:\Users\webbdam\Documents\AutoIt\Scripts\Test\review\" $sMovDate = 20090107 -1 $iMoved = _FileMoveByDate($sFldr, $sFldr2, "*", $sMovDate, 1, 0) If NOT @Error Then MsgBox(0, "Finished", $iMoved & " files were moved or copied") If $iMoved Then ShellExecute($sFldr2) Else MsgBox(0, "Error", "The error returned was " & @Error) EndIf Func _FileMoveByDate($sPath, $sNewPath, $sPattern = "*", $iDate = -1, $iDateFlag = 0, $iMove = 1, $iOverWrite = 1) Local $sHold, $aCreated, $iCreated, $iCount = 0 If StringRight($sPath, 1) <> "\" Then $sPath &= "\" If NOT FileExists($sPath) Then Return SetError(2) If StringRight($sNewPath, 1) <> "\" Then $sNewPath &= "\" If $iDateFlag > 2 OR $iDateFlag < 0 Then $iDateFlag = 1 If NOT FileExists($sNewPath) Then If NOT DirCreate($sNewPath) Then Return SetError(3) EndIf If $iDate = -1 Then $iDate = @Year & @Mon & @mDay $sFile = FileFindFirstFile($sPath & $sPattern) If NOT @Error Then If NOT FileExists($sNewPath) Then DirCreate($sNewPath) If $iOverWrite <> 1 Then $iOverWrite = 0 While 1 $sHold = FileFindNextFile($sFile) If @Error Then ExitLoop If StringInStr(FileGetAttrib($sHold), "D") Then ContinueLoop $aCreated = FileGetTime($sHold, $iDateFlag);; Might be better to use the 0 (modified) flag here $iCreated = $aCreated[0] & $aCreated[1] & $aCreated[2] If $iCreated >= $iDate Then If $iMove = 1 Then If NOT FileMove($sPath & $sHold, $sNewPath & $sHold, $iOverWrite) Then MsgBox(4096, "File Error", "Unable to Move The File " & $sHold) ContinueLoop EndIf Else If NOT FileCopy($sPath & $sHold, $sNewPath & $sHold, $iOverWrite) Then MsgBox(4096, "File Error", "Unable to Copy The File " & $sHold) ContinueLoop EndIf EndIf $iCount += 1 EndIf Wend Else Return SetError(1) EndIf Return $iCount EndFunc;<==> _FileMoveByDate() Any ideas?
  9. sorry i was just able to get this. It looks great. I'm gonna give it a shot here in a min. I'll let you know Thanks.
  10. im getting the following error: syntax check in scite passes, but it fails when run. Im still working to see what I did wrong, but as of this moment Im not sure. oh sorry this is the full code i have atm: $sFldr = "C:\Users\webbdam\Documents\test\" $sFldr2 = "C:\Users\webbdam\Documents\test\review\" $sMovDate = 20090107 -1 _FileMoveByDate($sFldr, $sFldr2, "*", $sMovDate) Func _FileMoveByDate($sPath, $sNewPath, $sPattern = "*", $iDate = -1) Local $sHold, $aCreated, $iCreated, $iCount = 0 If NOT FileExists($sNewPath) Then DirCreate($sNewPath) If $iDate = -1 Then $iDate = @Year & @Mon & @mDay $sFile = FileFindFirstFile($sPath & $sPattern) If NOT @Error Then While 1 $sHold = FileFindNextFile($sFile) If @Error Then ExitLoop If StringInStr(FileGetAttrib($sHold), "D") Then ContinueLoop $aCreated = FileGetTime($sHold, 1);; Migh be better to use the 0 (modified) flag here $iCreated = $aCreated[0] & $aCreated[1] & $aCreated[2] If $iCreated >= $iDate Then $iCount += 1 ;; Consider using FileCopy($sPath & $sHold, $sNewPath & $sHold, 1) here. FileMove($sPath & $sHold, $sNewPath & $sHold, 1) EndIf Wend EndIf MsgBox(0, "Finished", $iCount & " files were moved") If $iCount > 0 Then ShellExecute($sNewPath) EndFunc;<==> _FileMoveByDate()
  11. Ok cool thanks. I kinda figured it was supposed to be that way. Just wanted to be sure prior to running the script since this is a gov't PC.
  12. $sMovDate = @Year & @Mon & $mDay-1<---- is this just the current date (automatic) meaning it will alwas call the current date as it is when I run the script? Thats the way I understand it just trying to be clear. before I run any scripts (gov't pc) _FileMoveByDate($sFldr, $sFldr2, "*", $sMovDate)
  13. is this the way this should be written: $sFldr = @ScriptDir & "C:\Users\webbdam\Documents\test\"; or should it be $sFldr = "C:\Users\webbdam\Documents\test\" $sFldr2 = @DeskTopDir & "C:\Users\webbdam\Documents\test\review\"; or $sFldr2 = "C:\Users\webbdam\Documents\test\review\" _FileMoveByDate($sFldr, $sFldr2) Func _FileMoveByDate($sPath, $sNewPath, $sPattern = "*", $iDate = -1) Local $sHold, $aCreated, $iCreated, $iCount = 0 If NOT FileExists($sNewPath) Then DirCreate($sNewPath) If $iDate = -1 Then $iDate = @Year & @Mon & @mDay $sFile = FileFindFirstFile($sPath & $sPattern) If NOT @Error Then While 1 $sHold = FileFindNextFile($sFile) If @Error Then ExitLoop If StringInStr(FileGetAttrib($sHold), "D") Then ContinueLoop $aCreated = FileGetTime($sHold, 1);; Migh be better to use the 0 (modified) flag here $iCreated = $aCreated[0] & $aCreated[1] & $aCreated[2] If $iCreated >= $iDate Then $iCount += 1 ;; Consider using FileCopy($sPath & $sHold, $sNewPath & $sHold, 1) here. FileMove($sPath & $sHold, $sNewPath & $sHold, 1) EndIf Wend EndIf MsgBox(0, "Finished", $iCount & " files were moved") If $iCount > 0 Then ShellExecute($sNewPath) EndFunc ;<==> _FileMoveByDate()
  14. lol yea I just saw that too. getting ready to try that one out. thanks to you both. It looks like what I was trying to do.
  15. $t = FileGetTime(@Windowsdir & "\Notepad.exe", 1) If Not @error Then $yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2] MsgBox(0, "Creation date of notepad.exe", $yyyymd) EndIf FileMove("C:\foo.au3", "D:\mydir\bak.au3") ; Second example: ; uses flags '1' (owerwriting) and '8' (autocreating target dir structure) together ; moves all txt-files from temp to txtfiles and prechecks if ; target directory structure exists, if not then automatically creates it FileMove(@TempDir & "\*.txt", @TempDir & "\TxtFiles\", 9) Im not exactly sure how to get the output of Filegettime to work the way I want it to. I mean i can see that it will output the current date and time, but how do i get it to work using if,then, endif? if filegettime; <----greater than the last time the script was run... meaning I have this script write to a txt log..appending it everytime I run the script, a date and time. Once those dates and times are written, it uses the latest date and time to determine how many new files were created since then. If there are files it then moves them, if there are not it does nothing. so the script would move to the Then filemove c:\blah\*.* to c:\blah\for review\*.* else endif I am hoping someone can help me make heads or tails of this. thanks.
  16. k let me give that a try
  17. Does anyone know a simple code that has been written, or can be written that can assist me in moving files from one folder to another based on the date they were created? Specifically if they were created in the last day. I would only want hose files moved from the directory that they were created in, and placed in to a different folder for my review. Also can if someone could provide a visual que for me to see that it was accomplished. that would be helpful. thanks.
  18. anyone have any ideas on how i can get this script to work?
  19. yea ok I just tried that script. However, it doesn't do what I am looking for. It only returns the scripts that are in the same directory that I am in. I want it to return the all the files that are located on the d: drive regardless of what directories that they are in.
  20. cool I havent tried it yet, as im working on a paper for school but i do so and let you know how it turned out for me.
  21. You are referring to this set up right? #include <array.au3> $Path = @ScriptDir $Array = RecursiveFileSearch($path, "\.(au3)", true) _ArrayDisplay($Array) #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: WeaponX Updated: 2/21/08 Script Function: Recursive file search 2/21/08 - Added pattern for folder matching, flag for return type 1/24/08 - Recursion is now optional Parameters: RFSstartdir: Path to starting folder RFSFilepattern: RegEx pattern to match "\.(mp3)" - Find all mp3 files - case sensitive (by default) "(?i)\.(mp3)" - Find all mp3 files - case insensitive "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive RFSFolderpattern: "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default) "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive "(?!(Music|Movies)\b)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default) RFSFlag: Specifies what is returned in the array 0 - Files and folders 1 - Files only 2 - Folders only RFSrecurse: TRUE = Recursive, FALSE = Non-recursive RFSdepth: Internal use only #ce ---------------------------------------------------------------------------- Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = true, $RFSdepth = 0) ;Ensure starting folder has a trailing slash If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\" If $RFSdepth = 0 Then ;Get count of all files in subfolders for initial array definition $RFSfilecount = DirGetSize($RFSstartDir, 1) ;File count + folder count (will be resized when the function returns) Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1] EndIf $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*") If @error Then Return ;Search through all files and folders in directory While 1 $RFSnext = FileFindNextFile($RFSsearch) If @error Then ExitLoop ;If folder and recurse flag is set and regex matches If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then If $RFSrecurse AND StringRegExp($RFSnext, $RFSFolderpattern, 0) Then RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1) If $RFSFlag <> 1 Then ;Append folder name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf EndIf ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) AND $RFSFlag <> 2 Then ;Append file name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf WEnd FileClose($RFSsearch) If $RFSdepth = 0 Then Redim $RFSarray[$RFSarray[0] + 1] Return $RFSarray EndIf EndFunc;==>RecursiveFileSearch
  22. Thanks I will test that out a little later
  23. I checked out those posts. The issue is though I am not familiar enough with the autoit code to even understand how to implement those examples with what I want to do. For example: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: WeaponX Updated: 2/21/08 Script Function: Recursive file search 2/21/08 - Added pattern for folder matching, flag for return type 1/24/08 - Recursion is now optional Parameters: RFSstartdir: Path to starting folder RFSFilepattern: RegEx pattern to match "\.(mp3)" - Find all mp3 files - case sensitive (by default) "(?i)\.(mp3)" - Find all mp3 files - case insensitive "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive RFSFolderpattern: "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default) "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive "(?!(Music|Movies)\b)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default) RFSFlag: Specifies what is returned in the array 0 - Files and folders 1 - Files only 2 - Folders only RFSrecurse: TRUE = Recursive, FALSE = Non-recursive RFSdepth: Internal use only #ce ---------------------------------------------------------------------------- Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = true, $RFSdepth = 0) ;Ensure starting folder has a trailing slash If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\" If $RFSdepth = 0 Then ;Get count of all files in subfolders for initial array definition $RFSfilecount = DirGetSize($RFSstartDir, 1) ;File count + folder count (will be resized when the function returns) Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1] EndIf $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*") If @error Then Return ;Search through all files and folders in directory While 1 $RFSnext = FileFindNextFile($RFSsearch) If @error Then ExitLoop ;If folder and recurse flag is set and regex matches If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then If $RFSrecurse AND StringRegExp($RFSnext, $RFSFolderpattern, 0) Then RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1) If $RFSFlag <> 1 Then ;Append folder name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf EndIf ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) AND $RFSFlag <> 2 Then ;Append file name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf WEnd FileClose($RFSsearch) If $RFSdepth = 0 Then Redim $RFSarray[$RFSarray[0] + 1] Return $RFSarray EndIf EndFunc;==>RecursiveFileSearch I took this one which was labeled #1 for speed reasons, and tried to use it, but Um to say the least I'm lost. I dont understand what I am looking at. Its like a foreign language to me.
  24. Hmm maybe I am missing something, but when I chose my source and destination entered the extension, but nothing happened. No files were moved. I dont think it ran the dos portion of the script.
  25. K let me give that a try
×
×
  • Create New...