Sign in to follow this  
Followers 0
smstroble

moving contents of folder

7 posts in this topic

#1 ·  Posted (edited)

Ok i must be missing something here. :P im trying to move the contents of a folder but not the folder its self. Filemove("sourcefoler\*", "destnationfolder", 1) works greak for the files but i cant figure a way to move the folders in the folder, using DirMove which moved the source folder which i dont want to do. is there anyway to search for the subdirectorys within a directory?

thanks for your help :)

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <file.au3>
Func _MoveFilesAndDirectories($srcFolder, $srcDest)
    Local $avFilesArray = _FileListToArray($srcFolder)
    For $i = 1 to $avFilesArray[0]
        if (FileGetSize($avFilesArray[$i]) <= 0) Then ;Checks if its a folder or a file.
            DirCopy($srcFolder & "\" & $avFilesArray[$i], $srcDest & "\" & $avFilesArray[$i] & "\")
        Else
            FileCopy($srcFolder & "\" & $avFilesArray[$i], $srcDest & "\" & $avFilesArray[$i])
        EndIf
    Next
EndFunc
    
_MoveFilesAndDirectories("Glib", "test")

hmm, this seems to work for me :)

Thats what you're looking for right?

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks so much, been looking for this for hours.. :)

knew i was missing something simple.

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

hmm dident work quite right..

so i fixed it! :)

Func _MoveFilesAndDirectories($srcFolder, $srcDest)
    Local $avFilesArray = _FileListToArray($srcFolder)
    For $i = 1 To $avFilesArray[0]
        if (FileGetSize($srcFolder & "\" & $avFilesArray[$i]) <= 0) Then ;Checks if its a folder or a file.
            DirMove($srcFolder & "\" & $avFilesArray[$i], $srcDest & "\" & $avFilesArray[$i])
        Else
            FileMove($srcFolder & "\" & $avFilesArray[$i], $srcDest & "\", 8)
        EndIf
    Next
EndFunc

edit: minor code simplification

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ah! I forgot to add the $srcFolder & "\". lol.

Strange though because it worked for me..

sry

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

FileCopy($avFilesArray[$i]
very strange indeed you dident close the () for the filecopy function

anyway np thanks much for the help :P

incase your wondering what im working on im makeing a "real" desktop switcher. real meaning it will have unique desktop icons/items for each virtual desktop. only been able to find one other program like it and its $25 :)


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

hmmmmm.... maybe i accidently erased that when i was editing it :)

but np. Sounds like a nice prgram!

Edited by CHRIS95219

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