Jump to content
Sign in to follow this  
n9mfk9

not get sub dir?

Recommended Posts

n9mfk9

Hi All,

here is my code

it copies all file but no sub dir even tho thay are on there on the list

an dircopy will not work

#Include <File.au3>

#Include <Array.au3>

DirCreate("C:\new\wd14\")

$FileList=_FileListToArray("C:\wdisplay/","*.*",0)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

_ArrayDisplay($FileList,"$FileList")

For $n= 1 to $FileList[0]

FileCopy("C:\wdisplay\"&$FileList[$n],"C:\new\wd15\",8)

Next

what havi i missed

Share this post


Link to post
Share on other sites
Achilles

Hi All,

here is my code

it copies all file but no sub dir even tho thay are on there on the list

an dircopy will not work

#Include <File.au3>

#Include <Array.au3>

DirCreate("C:\new\wd14\")

$FileList=_FileListToArray("C:\wdisplay/","*.*",0)

If @Error=1 Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

_ArrayDisplay($FileList,"$FileList")

For $n= 1 to $FileList[0]

FileCopy("C:\wdisplay\"&$FileList[$n],"C:\new\wd15\",8)

Next

what havi i missed

You're going to have to use DirCopy() for the folders...

Here:

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

$originalDir = @DesktopDir & '\My Programs'

DirCreate("C:\new\wd14\")

$FileList=_FileListToArray($originalDir,"*.*",1)
$FolderList=_FileListToArray($originalDir, '**', 2)

If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

_ArrayDisplay($FileList,"$FileList")
_ArrayDisplay($FolderList,'$FolderList')

For $n= 1 to $FileList[0]
    FileCopy($originalDir,"C:\new\wd15\",8)
Next

For $n= 1 to $FolderList[0] 
    DirCopy($originalDir,"C:\new\wd15\",1)
Next
Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
tAKTelapis

I assume the sub dirs it is missing are empty, correct?

You are doing a "filecopy" command on each value of an array.

Unfortuneately it is going to come across items which are not FILES but are in fact FOLDERS (or directories) Its going to be lost as it cannot handle them the same, and they are empty.. if there was a file inside, it would take your flag into account and create the directory for the file to live in.

Here is an excerpt from a script i have which deals with files and folders, it is able to recognize the difference and should let you add an IF statement to see if it is a file to be copied over, or a directory to be made, this way you force the script to manually create the directories for you.

I can provide this entire script if you need for reference, but this should be enough to modify to your needs.

or $x = 1 To $a_FilesToInstall[0] - 1
    $IsNotAFolder = FileGetAttrib($a_FilesToInstall[$x])
    If StringInStr("D", $IsNotAFolder, 0) >= 1 Then
        FileWriteLine($au3ScriptFile, 'DirCreate("' & $a_FilesToInstall[$x] & '")')
        FileWriteLine($au3ScriptFile, 'ProgressSet(' & $Progress & ', "", "Now Installing File ' & $x & '")')
        ContinueLoop
    Else
        FileWriteLine($au3ScriptFile, 'FileInstall("' & $a_FilesToInstall[$x] & '", "' & $a_FilesToInstall[$x] & '", 1)')
        FileWriteLine($au3ScriptFile, 'ProgressSet(' & $Progress & ', "", "Now Installing File ' & $x & '")')
    EndIf
    $Progress = $Progress + $ProgressIncrement
Next
Edited by tAKTelapis

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  

×