zufälliges kopieren bis 2gb

  • hi,

    ich habe eine HD mit Musik.... 37GB... jetzt wollte ich mir einen MP3Player-Stick kaufen
    und dann hin und wieder die Musik wechseln.
    Kann ich mit Autoit sowas wie einen Zufallskopierer machen, der aus einem Ordner (bei mir MP3)
    mit 30 oder mehr Ordnern in denen die mp3 Tracks sind diese frei auswählt, auf USBPlayer kopiert und eine Text-Datei anlegt, welsche Tracks kopiert wurden. Beim nächsten mal sollte er diese Datei auslesen und andere Tracks nehmen..... Und er sollte wissen wann der Stick (2GB) voll ist
    und automatisch fertig sagen...

    Ist das mit Autoit überhaupt möglich???


    Also schreibt fleißig obs geht oder nicht ...


    Chicago

  • hi,

    das sollte keine bitte sein, das mir das einer schreibt.... th.meger...
    war eigendlich mehr als frage gedacht ob sowas überhaupt geht...

    aber trotzdem danke für die antworten..... werd mal schauen wie ich anfangen werde ....


    grüße

    Chicago

    • Offizieller Beitrag

    Hallo!

    Ein anfang ist schonmal hier, ist nochnich komplett, aber ich hab die nächsten tage leider wenig zeit (erst wider ab freitag richtig zeit dafür..) also wenn du es weiter progn willst.. dann hier ;) wenn du noch iwelche fragen hast stehe ich dir natürlich bei (z.b. @icq)

    also hier der anfang:

    Spoiler anzeigen
    [autoit]

    #include <file.au3>
    #include <array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $hwndSpl, $SplNext = 1, $SplText, $FileList, $size = 0
    Global $ListTxt = @ScriptDir & "\List.txt"
    Global $ListTxtOp = FileOpen($ListTxt, 1)
    Global $FilesToCopy[1]

    [/autoit] [autoit][/autoit] [autoit]

    If FileGetSize($ListTxt) Then _ReadFromList()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;DIESE DATEN MUSST DU NACH DEINEN WÜNSCHEN BEARBEITEN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    If Not Eval("MusicDir") Then Global Const $MusicDir = @ScriptDir
    Global Const $SizeInByte = 20 * 1048576 ;1048576 = mb
    Global Const $DestDir = "D:\wg"
    Global Const $MusicDirName = StringTrimLeft($MusicDir, StringInStr($MusicDir, "\", 0, -1))

    [/autoit] [autoit][/autoit] [autoit]

    If Not IsArray($FileList) Then _ReadMusicDir()

    [/autoit] [autoit][/autoit] [autoit]

    $SplText = "Lese größe der Daten"
    $hwndSpl = SplashTextOn("", $SplText & @LF & "|", 250, 65, -1, -1, 1, "Courier New")
    AdlibEnable("_SetSpl", 100)
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    $i = 0
    While 1
    $i += 1
    $rand = Random(1, $FileList[0], 1)
    $size += FileGetSize($FileList[$rand])
    If $size > $SizeInByte Then ExitLoop
    ReDim $FilesToCopy[$i+1]
    $FilesToCopy[$i] = $FileList[$rand]
    _FileWriteToLine($ListTxt,$rand,"",1)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    $SplText = "Kopiere Daten"&@LF&""

    [/autoit] [autoit][/autoit] [autoit]

    $to = $i - 1
    For $i = 1 To $to
    $SplText = "Kopiere Daten"&@LF&StringTrimLeft($FilesToCopy[$i],StringInStr($FilesToCopy[$i],"\",0,-1))
    FileCopy($FilesToCopy[$i], $DestDir&"\*.*", 1)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    SplashOff()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ReadMusicDir()
    $SplText = "Lese den Musikordner ein"&@LF&$MusicDirName
    $hwndSpl = SplashTextOn("", $SplText & @LF & "|", 250, 40, -1, -1, 1, "Courier New")
    AdlibEnable("_SetSpl", 100)
    $FileList = _FileListToArrayEx($MusicDir, "*.*", 1, '', True)
    SplashOff()
    AdlibDisable()
    FileWriteLine($ListTxtOp, $MusicDir)
    For $i = 1 To $FileList[0]
    FileWriteLine($ListTxtOp, StringTrimLeft($FileList[$i], StringLen($MusicDir) + 1))
    Next
    EndFunc ;==>_ReadMusicDir

    [/autoit] [autoit][/autoit] [autoit]

    Func _ReadFromList()
    $SplText = "Lese daten von Datei"&@LF&StringTrimLeft($ListTxt,StringInStr($ListTxt,"\",0,-1))
    $hwndSpl = SplashTextOn("", $SplText & @LF & "|", 250, 65, -1, -1, 1, "Courier New")
    AdlibEnable("_SetSpl", 100)
    _FileReadToArray($ListTxt, $FileList)
    Global $MusicDir = $FileList[1]
    $FileList[0] = $FileList[0] - 1
    _ArrayDelete($FileList, 1)
    For $i = 1 To $FileList[0]
    $FileList[$i] = $MusicDir & "\" & $FileList[$i]
    If Not FileExists($FileList[$i]) Then MsgBox(0, "", $FileList[$i])
    Next
    SplashOff()
    EndFunc ;==>_ReadFromList

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _SetSpl()
    Switch $SplNext
    Case 1
    ControlSetText($hwndSpl, "", "Static1", $SplText & @LF & "./.")
    $SplNext = 2
    Case 2
    ControlSetText($hwndSpl, "", "Static1", $SplText & @LF & "..-..")
    $SplNext = 3
    Case 3
    ControlSetText($hwndSpl, "", "Static1", $SplText & @LF & "...\...")
    $SplNext = 4
    Case 4
    ControlSetText($hwndSpl, "", "Static1", $SplText & @LF & "|")
    $SplNext = 1
    EndSwitch
    EndFunc ;==>_SetSpl

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Description: lists all or preferred files and or folders in a specified path (Similar to using Dir with the /B Switch)
    ; Syntax: _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '', $bTmpFile = False)
    ; Parameter(s): $sPath = Path to generate filelist for
    ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details, support now for multiple searches
    ; Example *.exe; *.txt will find all .exe and .txt files
    ; $iFlag = determines weather to return file or folders or both.
    ; $sExclude = exclude a file from the list by all or part of its name
    ; Example: Unins* will remove all files/folders that start with Unins
    ; $iFlag=0(Default) Return both files and folders
    ; $iFlag=1 Return files Only
    ; $iFlag=2 Return Folders Only
    ; $bTmpFile = Boolean value for specifying if using a temp. file
    ; $bTmpFile = True All files are written to a "reserved" .tmp file (Thanks to gafrost) for the example
    ; The Reserved file is then read into an array, then deleted
    ; $bTmpFile = False No .tmp file is used
    ; Requirement(s): None
    ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path
    ; On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
    ; @Error or @extended = 1 Path not found or invalid
    ; @Error or @extended = 2 Invalid $sFilter or Invalid $sExclude
    ; @Error or @extended = 3 Invalid $iFlag
    ; @Error or @extended = 4 No File(s) Found
    ; Author(s): SmOke_N
    ; Note(s): The array returned is one-dimensional and is made up as follows:
    ; $array[0] = Number of Files\Folders returned
    ; $array[1] = 1st File\Folder
    ; $array[2] = 2nd File\Folder
    ; $array[3] = 3rd File\Folder
    ; $array[n] = nth File\Folder
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '', $iRecurse = False, $iShortName = True)
    If Not FileExists($sPath) Then Return SetError(1, 1, '')
    If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*'
    If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0
    If $sExclude = -1 Or $sExclude = Default Then $sExclude = ''
    Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|']
    $sFilter = StringRegExpReplace($sFilter, '\s*;\s*', ';')
    If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
    For $iCC = 0 To 5
    If StringInStr($sFilter, $aBadChar[$iCC]) Or _
    StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '')
    Next
    If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '')
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '')
    Local $oFSO = ObjCreate("Scripting.FileSystemObject"), $sTFolder
    $sTFolder = $oFSO.GetSpecialFolder (2)
    Local $hOutFile = @TempDir & $oFSO.GetTempName
    If Not StringInStr($sFilter, ';') Then $sFilter &= ';'
    Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead, $sHoldSplit
    For $iCC = 1 To $aSplit[0]
    If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop
    If StringLeft($aSplit[$iCC], 1) = '.' And _
    UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then $aSplit[$iCC] = '*' & $aSplit[$iCC]
    $sHoldSplit &= '"' & $sPath & $aSplit[$iCC] & '" '
    Next
    $sHoldSplit = StringTrimRight($sHoldSplit, 1)
    If $iRecurse Then
    RunWait(@ComSpec & ' /c dir /b /s /a ' & $sHoldSplit & ' > "' & $hOutFile & '"', '', @SW_HIDE)
    Else
    RunWait(@ComSpec & ' /c dir /b /a ' & $sHoldSplit & ' /o-e /od > "' & $hOutFile & '"', '', @SW_HIDE)
    EndIf
    $sRead &= FileRead($hOutFile)
    If Not FileExists($hOutFile) Then Return SetError(4, 4, '')
    FileDelete($hOutFile)
    If StringStripWS($sRead, 8) = '' Then SetError(4, 4, '')
    Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF)
    Local $sHold
    For $iCC = 1 To $aFSplit[0]
    If $sExclude And StringLeft($aFSplit[$iCC], _
    StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then ContinueLoop
    Switch $iFlag
    Case 0
    If StringLeft($aFSplit[$iCC], StringLen($sPath)) <> $sPath Then
    If $iShortName Then
    $sHold &= FileGetShortName($sPath & $aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $sPath & $aFSplit[$iCC] & Chr(1)
    EndIf

    Else
    If $iShortName Then
    $sHold &= FileGetShortName($aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $aFSplit[$iCC] & Chr(1)
    EndIf

    EndIf
    Case 1
    If StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    If StringLeft($aFSplit[$iCC], StringLen($sPath)) <> $sPath Then
    If $iShortName Then
    $sHold &= FileGetShortName($sPath & $aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $sPath & $aFSplit[$iCC] & Chr(1)
    EndIf
    Else
    If $iShortName Then
    $sHold &= FileGetShortName($aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $aFSplit[$iCC] & Chr(1)
    EndIf
    EndIf
    Case 2
    If Not StringInStr(FileGetAttrib($sPath & '\' & $aFSplit[$iCC]), 'd') Then ContinueLoop
    If StringLeft($aFSplit[$iCC], StringLen($sPath)) <> $sPath Then
    If $iShortName Then
    $sHold &= FileGetShortName($sPath & $aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $sPath & $aFSplit[$iCC] & Chr(1)
    EndIf
    Else
    If $iShortName Then
    $sHold &= FileGetShortName($aFSplit[$iCC]) & Chr(1)
    Else
    $sHold &= $aFSplit[$iCC] & Chr(1)
    EndIf
    EndIf
    EndSwitch
    Next
    $sHold = StringReplace(StringReplace(StringReplace(StringReplace($sHold, Chr(129), "ü"), Chr(132), "ä"), Chr(148), "ö"), Chr(225), "ß")
    If StringTrimRight($sHold, 1) Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1))
    Return SetError(4, 4, '')
    EndFunc ;==>_FileListToArrayEx

    [/autoit]

    Mfg Spider