Jump to content

Moving files that are not as followed.


Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...