Guest User

Untitled

a guest
Dec 4th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.04 KB | None | 0 0
  1. #include <Array.au3>
  2. #include <File.au3>
  3.  
  4. If MsgBox(4,"","Fortfahren?") = 7 Then Exit
  5.  
  6. $files = _GetFilesFolder_Rekursiv(@ScriptDir)
  7.  
  8. For $i = 1 To $files[0] Step 1
  9.    If StringInStr($files[$i],".jpg") Or StringInStr($files[$i],".png") Or StringInStr($files[$i],".avi") Or StringInStr($files[$i],".mp4") Then
  10.       FileDelete($files[$i])
  11.    EndIf
  12. Next
  13.  
  14. MsgBox(0,"Fertig","Fertig, Maru")
  15.  
  16. Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0')
  17.     Global $oFSO = ObjCreate('Scripting.FileSystemObject')
  18.     Global $strFiles = ''
  19.     Switch $sDelim
  20.         Case '1'
  21.             $sDelim = @CR
  22.         Case '2'
  23.             $sDelim = @LF
  24.         Case '3'
  25.             $sDelim = ';'
  26.         Case '4'
  27.             $sDelim = '|'
  28.         Case Else
  29.             $sDelim = @CRLF
  30.     EndSwitch
  31.     If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0
  32.     If $sExt = -1 Then $sExt = '*'
  33.     If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1
  34.     _ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim)
  35.     If $iRetType = 0 Then
  36.         Local $aOut
  37.         $aOut = StringSplit(StringTrimRight($strFiles, StringLen($sDelim)), $sDelim, 1)
  38.         If $aOut[1] = '' Then
  39.             ReDim $aOut[1]
  40.             $aOut[0] = 0
  41.         EndIf
  42.         Return $aOut
  43.     Else
  44.         Return StringTrimRight($strFiles, StringLen($sDelim))
  45.     EndIf
  46. EndFunc
  47.  
  48. Func _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF)
  49.     If Not IsDeclared("strFiles") Then Global $strFiles = ''
  50.     If ($Dir = -1) Or ($Dir = 0) Then
  51.         For $file In $Folder.Files
  52.             If $Ext <> '*' Then
  53.                 If StringRight($file.Name, StringLen($Ext)) = $Ext Then _
  54.                     $strFiles &= $file.Path & $Delim
  55.             Else
  56.                 $strFiles &= $file.Path & $Delim
  57.             EndIf
  58.         Next
  59.     EndIf
  60.     For $Subfolder In $Folder.SubFolders
  61.         If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim
  62.         _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim)
  63.     Next
  64. EndFunc
Add Comment
Please, Sign In to add comment