Jump to content

I need a push - Copying files from directory based on file name in txt


Recommended Posts

Been a while since I've used autoit, and kind of out of touch with it. So I need a little push in right direction on where to start with this. Basically I have a txt file with a bunch of file names (just the name, no extention). Then I have a directory with thousands of files, including all of the file names that are in my text file. I need a way to extract those that are in the list, or delete all that are not in the list.

Link to comment
Share on other sites

Hey

One way would be to use _FileListToArray() on the folder in question, then filereadline() the textfile, and do a arraysearch(). After finding the file you can move it, or add it to a move list or something

something like this

$keep = fileopen("list.txt",0)

$currentlist = _FileListToArray($folderpath)
_ArrayTrim($currentlist,3,1)

do
    $file = filereadline($keep)
    $err = @error

    _arraysearch(...)

    filemove()

until $err =-1

This code is just a guide, not a working script :idea:

(You can also look at reading the text then using FileFindFirstFile() to find it and move it)

This is probably not the most efficient way, but It will work.

Edited by hawky358
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...