Sign in to follow this  
Followers 0
ffdshow

_FileListToArray problem

3 posts in this topic

#1 ·  Posted (edited)

I use the next code to create archive from only the content of 2 subdirs placed in @ScriptDir, but total size of archives is 3x subdirs size. Other problem is that the script will add to archive all files from @ScriptDir. The command line syntax is OK.

#Include <File.au3>
#Include <Array.au3>

$VolumeSize = "100m"
$SetAPasswordForArchives = 1
$Password = "qwerty"
$EncryptFileNames = 1

$FolderList = _FileListToArray(@ScriptDir, "*", 2)
Select
    Case $SetAPasswordForArchives = 1 and $EncryptFileNames = 1
        If IsArray($FolderList) Then
            For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & '"' & $FolderList[$i] & '"')
            RunWait("RAR.exe a -m0 -r -v" & $VolumeSize & " -hp" & $Password & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
            Next
        EndIf
    Case $SetAPasswordForArchives = 1 and $EncryptFileNames = 0
        If IsArray($FolderList) Then
            For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & '"' & $FolderList[$i] & '"')
            RunWait("RAR.exe a -m0 -r -v" & $VolumeSize & " -p" & $Password & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
            Next
        EndIf
    Case $SetAPasswordForArchives = 0
        If IsArray($FolderList) Then
            For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & '"' & $FolderList[$i] & '"')
            RunWait("RAR.exe a -m0 -r -v" & $VolumeSize & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
            Next
        EndIf
EndSelect
Edited by ffdshow

Share this post


Link to post
Share on other sites



Hi there,

Remember that _filelisttoarray is an array, and the $FolderList[0] is the number of records in the array. Search for UBOUND command

try :

$limit = ubound ($folderlist)-1
For $i = 1 to $limit

For the RAR issue:

try :

RunWait("RAR.exe a -m0 -r -v" & $VolumeSize & " -hp" & $Password & " " & '"' & $FolderList[$i] & '"', @ScriptDir & "\" & '"' & $FolderList[$i] & '"')

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Rar synthax is OK. I guess is something wrong with those case statements.

Edit

This code works:

$VolumeSize = "100m"
$SetAPasswordForArchives = 1
$Password = "qwerty"
$EncryptFileNames = 1

#Include <File.au3>
#Include <Array.au3>
If $SetAPasswordForArchives = 1 And $EncryptFileNames = 1 Then
    $FolderList = _FileListToArray(@ScriptDir, "*", 2)
    If IsArray($FolderList) Then
        For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & $FolderList[$i])
            RunWait('"' & @ScriptDir & "\RAR.exe" & '"' & " a -m0 -r -v" & $VolumeSize & " -hp" & $Password & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
        Next
    EndIf
EndIf

If $SetAPasswordForArchives = 1 And $EncryptFileNames = 0 Then
    $FolderList = _FileListToArray(@ScriptDir, "*", 2)
    If IsArray($FolderList) Then
        For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & $FolderList[$i])
            RunWait('"' & @ScriptDir & "\RAR.exe" & '"' & " a -m0 -r -v" & $VolumeSize & " -p" & $Password & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
        Next
    EndIf
EndIf

If $SetAPasswordForArchives = 0 Then
    $FolderList = _FileListToArray(@ScriptDir, "*", 2)
    If IsArray($FolderList) Then
        For $i = 1 to $FolderList[0]
            FileChangeDir(@ScriptDir & "\" & $FolderList[$i])
            RunWait('"' & @ScriptDir & "\RAR.exe" & '"' & " a -m0 -r -v" & $VolumeSize & " " & '"' & $FolderList[$i] & '"')
            FileMove(@ScriptDir & "\" & $FolderList[$i] & "\" & $FolderList[$i] & "*.rar", @ScriptDir, 1)
        Next
    EndIf
EndIf
Edited by ffdshow

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