Jump to content

Recommended Posts

Posted

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

Posted

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!

Posted

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!

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
×
×
  • Create New...