Created
May 16, 2026 19:34
-
-
Save mistic100/1b9370cd25e88ff901125b2d35902fbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; AutoIt script to automatically move downloaded files of a certain extension to another folder | |
| #include <WinAPIFiles.au3> | |
| #include <WinAPIMisc.au3> | |
| #include <APIFilesConstants.au3> | |
| Local $sourceDir = "A:\Downloads\" | |
| Local $destDir = "\\NAS\downloads\" | |
| Local $extension = ".torrent" | |
| OnAutoItExitRegister('OnAutoItExit') | |
| Local $hDirectory = _WinAPI_CreateFileEx($sourceDir, $OPEN_EXISTING, $FILE_LIST_DIRECTORY, BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE), $FILE_FLAG_BACKUP_SEMANTICS) | |
| If @error Then | |
| _WinAPI_ShowLastError('', 1) | |
| EndIf | |
| Local $pBuffer = _WinAPI_CreateBuffer(65536) | |
| Local $aData | |
| While 1 | |
| $aData = _WinAPI_ReadDirectoryChanges($hDirectory, $FILE_NOTIFY_CHANGE_FILE_NAME, $pBuffer, 65536, False) | |
| If Not @error Then | |
| For $i = 1 To $aData[0][0] | |
| If $aData[$i][1] = 1 And StringRight($aData[$i][0], StringLen($extension)) = $extension Then | |
| Sleep(1000) | |
| FileMove($sourceDir & "\" & $aData[$i][0], $destDir & $aData[$i][0]) | |
| If @error Then | |
| _WinAPI_ShowLastError('', 1) | |
| EndIf | |
| EndIf | |
| Next | |
| Else | |
| _WinAPI_ShowLastError('', 1) | |
| EndIf | |
| Sleep(100) | |
| WEnd | |
| Func OnAutoItExit() | |
| _WinAPI_FreeMemory($pBuffer) | |
| _WinAPI_CloseHandle($hDirectory) | |
| EndFunc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment