Jump to content
Sign in to follow this  
stg68

Moving files that are not as followed.

Recommended Posts

stg68

What is the best method of moving files from one directory to another by excluding files by name.

For instance, Move all files from directory A to directory B where file names are not FirstFile.txt, SecondFile.txt and ThirdFile.txt

Best Regards

Share this post


Link to post
Share on other sites
monoceres

Quick example, storing excluded files in array :)

#include <file.au3>
Global $dir1="C:\test", $dir2="C:\test2"
Global $excludes[3]=["FirstFile.txt","SecondFile.txt","ThirdFile.txt"]
$files=_FileListToArray($dir1,"*",1)
If UBound($files)>1 Then
For $file In $files
    For $exclude In $excludes
        If $file=$exclude Then
            ContinueLoop 2
        EndIf
    Next
    FileMove($dir1&"\"&$file,$dir2&"\"&$file,9)
Next
EndIf

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
stg68

Quick example, storing excluded files in array :)

#include <file.au3>
Global $dir1="C:\test", $dir2="C:\test2"
Global $excludes[3]=["FirstFile.txt","SecondFile.txt","ThirdFile.txt"]
$files=_FileListToArray($dir1,"*",1)
If UBound($files)>1 Then
For $file In $files
    For $exclude In $excludes
        If $file=$exclude Then
            ContinueLoop 2
        EndIf
    Next
    FileMove($dir1&"\"&$file,$dir2&"\"&$file,9)
Next
EndIf

Cool! THANKS A LOT!

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  

×