Sign in to follow this  
Followers 0
afcartman

need help with some code

2 posts in this topic

I want to add a piece of code to my program that will move all the things on the users desktop into a different folder. This is the code I've tried but it doesn't work...just to give you an idea of what I'm trying ot get done.

$search = FileFindFirstFile(@DesktopDir & "*.*")  

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $a = FileGetLongName($file)
    FileMove($a, "C:\mydir")
WEnd






FileClose($search)

Share this post


Link to post
Share on other sites



Try this. You forgot to add the "\" to separate the file name from the folder name.

$search = FileFindFirstFile(@DesktopDir & "\*.*")  

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $a = FileGetLongName($file)
    FileMove($a, "C:\mydir")
WEnd

FileClose($search)

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