Jump to content

Automated File Management: Using AUTOIT to Prevent Desktop Clutter by Moving New Files to a Specific Folder - (Moved)


Ilounah
 Share

Recommended Posts

  • Developers

Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Oh well, there you go...

#include <File.au3>

HotKeySet("!{ESC}", _Exit)
Main(@DesktopDir, "C:\Apps\Temp")

Func Main($sSourceDir, $sTargetDir)
  Local $aBase = _FileListToArray($sSourceDir)
  ;_ArrayDisplay ($aBase)
  Local $aList

  While Sleep(5 * 1000) ; check every 5 secs
    $aList = _FileListToArray($sSourceDir)
    For $i = 1 To $aList[0]
      _ArraySearch($aBase, $aList[$i], 1)
      If @error Then
        ; do not use FileMove : under some circumstances it may not work properly
        FileCopy($sSourceDir & "\" & $aList[$i], $sTargetDir & "\" & $aList[$i], $FC_OVERWRITE)
        FileDelete($sSourceDir & "\" & $aList[$i])
      EndIf
    Next
  WEnd
EndFunc   ;==>Main

Func _Exit()
  Exit
EndFunc   ;==>_Exit

 

Edited by Nine
Link to comment
Share on other sites

@Nine  directory friendly :)

#include <File.au3>

HotKeySet("!{ESC}", _Exit)
Main(@DesktopDir, "C:\Apps\Temp")

Func Main($sSourceDir, $sTargetDir)
    Local $aBase = _FileListToArray($sSourceDir)
;~   _ArrayDisplay ($aBase)
    Local $aList
    While Sleep(10 * 1000) ; check every 10 secs
        $aList = _FileListToArray($sSourceDir)
        For $i = 1 To $aList[0]
            _ArraySearch($aBase, $aList[$i], 1)
            If @error Then
                ; do not use FileMove : under some circumstances it may not work properly
                If StringInStr(FileGetAttrib($sSourceDir & "\" & $aList[$i]), "D") = 0 Then
                    FileCopy($sSourceDir & "\" & $aList[$i], $sTargetDir & "\" & $aList[$i], $FC_OVERWRITE)
                    FileDelete($sSourceDir & "\" & $aList[$i])
                Else
                    DirCopy($sSourceDir & "\" & $aList[$i], $sTargetDir & "\" & $aList[$i], $FC_OVERWRITE)
                    DirRemove($sSourceDir & "\" & $aList[$i], 1)
                EndIf
            EndIf
        Next
    WEnd
EndFunc   ;==>Main

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

I know that I know nothing

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...