Sign in to follow this  
Followers 0
Nirvana6

Explicit Content Audio Remover

15 posts in this topic

This script should perform a computer scan for some keywords in all the computer and delete the files/folders found containing one or more of the keywords.

muttley

As I said i need some tips because I'm a noob :).

Please excuse my bad english (if it's present :()


Share this post


Link to post
Share on other sites



Something like this?

#include <File.au3>
#include <Array.au3>

RemoveFiles("MyMusic.mp3")

Func RemoveFiles($FileName, $sPath = @ScriptDir, $sFilter = "*")
    $fList = _FileListToArray($sPath, $sFilter)
; _ArrayDisplay($fList)
    If _ArraySearch($fList, $FileName) Then
        FileChangeDir($sPath)
        FileDelete($FileName); Delete file if match found!
        If Not @error Then ConsoleWrite("Deleted: " & $FileName & @CRLF)
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Some functions you might need:

  • FileFindFirstFile
  • FileFindNextFile
  • StringInStr
  • FileDelete
  • FileRecycle
  • _FileListToArray
  • For/Next loop
  • If/Then

@JamesBrooks, I think he's looking for in the name of the file, to have stuff like: "Shit", "Fuck", "Bitch", "Ass", and other curse words, then delete that file and move on.

Edited by Alienware

Share this post


Link to post
Share on other sites

Thanks! muttley

I played with those :

* FileFindFirstFile

* FileFindNextFile

* StringInStr

* FileDelete

* FileRecycle

* _FileListToArray

* For/Next loop

* If/Then

these days... :)

Now...

i guess that all i need to do now is to add more keywords...

Something like that :

#include <File.au3>
#include <Array.au3>

RemoveFiles("MyMusic.mp3")
RemoveFiles("Test1.mp3")

Func RemoveFiles($FileName, $sPath = @ScriptDir, $sFilter = "*")
    $fList = _FileListToArray($sPath, $sFilter)
; _ArrayDisplay($fList)
    If _ArraySearch($fList, $FileName) Then
        FileChangeDir($sPath)
        FileDelete($FileName); Delete file if match found!
        If Not @error Then ConsoleWrite("Deleted: " & $FileName & @CRLF)
    EndIf
EndFunc

right ?:(


Share this post


Link to post
Share on other sites

i added new keywords - works perfectly muttley

is there a way to check if something found is a file or a folder ?


Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sure is.

Func IsDirectory($FileName)
    $IsDir = FileGetAttrib($FileName)
    If $IsDir = "D" Then
        Return True
    Else
        Return False
    EndIf
EndFunc

@Alienware, an array with keywords looped will work muttley

Global $WhatWords[3] = ["Shit", "Fuck", "Bitch"]; Add more words

For $i = 0 to UBound($WhatWords) - 1
    RemoveFiles($WhatWords[$i], @ScriptDir, ".mp3")
Next

Woops, fixed the big with the array size being to big or small.

Edit again: You could also use StringInStr() to check if any of the files listed contained those words.

Edited by JamesBrooks

Share this post


Link to post
Share on other sites

Thanks again :-) !

I will post the code tomorrow (is 10:30 PM here muttley and i'm sleepy (sorry for offtopic) )


Share this post


Link to post
Share on other sites

Sure is.

-[clip]-

Woops, fixed the big with the array size being to big or small.

Edit again: You could also use StringInStr() to check if any of the files listed contained those words.

I would use StringInStr() For the FileGetAttrib() check Because the file could be a "hidden directory" or a "system directory" or something and FileGetAttrib() would return would be "HD" or "SD"

Share this post


Link to post
Share on other sites

That is true. So how would you search through the list of words in a filename then?

I'm just talking about this function here:

Func IsDirectory($FileName)
    $IsDir = FileGetAttrib($FileName)
    If StringInStr($IsDir,"D") Then ; NOTE: The StringInStr
        Return True
    Else
        Return False
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Recursive file search reference here:

http://www.autoitscript.com/forum/index.ph...rsivefilesearch

;Dirty words seperated by pipe symbol
$BadWords = "fuck|shit|piss|cunt|cock|yarbles|schwanzstucker"

;Search
$array = RecursiveFileSearch(@DesktopDir, "(?i)("&$BadWords&")", "", 1)
For $X = 1 to $array[0]
    ConsoleWrite('['&$X&']: ' & $array[$X] & @CRLF)
    ;FileDelete($array[$X])
Next

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($RFSstartDir & $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
Edited by weaponx

Share this post


Link to post
Share on other sites

Thanks to all of you muttley !


Share this post


Link to post
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
Sign in to follow this  
Followers 0