Find and copy file from a filelist.txt?

I might be biting off more than I can chew with this idea, thou I bet dopus can handle it, likely with a script.
my question is...


Can I provide dopus with a filelist.txt, that contains full paths to a list of files, then have dopus copy them to a particular directory?

or has anyone encounterd any other utilities that do a task like this?


I tried to ask chat gpt, thou it rarely provides working scripts, it gave me this... which errors out, naturally.

function OnClick(clickData)
{
    var fsu = DOpus.FSUtil;
    var sourcePath = clickData.func.sourcetab.path;
    var destPath = "C:\\copylist"; // Change this to your desired destination folder
    var fileList = fsu.ReadFile("C:\\copylist\\filelist.txt"); // Change this to your text file path
    
    if (fileList.error == 0)
    {
        var files = fileList.split("\n");
        for (var i = 0; i < files.length; i++)
        {
            var file = files[i].trim();
            if (file != "")
            {
                var fullPath = fsu.Resolve(sourcePath + "\\" + file);
                if (fsu.Exists(fullPath))
                {
                    DOpus.FSUtil.Copy(fullPath, destPath);
                }
            }
        }
    }
    else
    {
        DOpus.Output("Error reading file list.");
    }
}


If you haven't already seen it, this may be helpful...

You can also convert the file list into a collection and copy out of that:

https://docs.dopus.com/doku.php?id=reference:dopusrt_reference:external_manipulation_of_file_collections

1 Like

thank you! This was easy to figure out with dopus easy syntax.

I'm trying to set this up with inputs.
is there a way to hold onto the var of the first box and get it to the file select box in this case??

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /col create /ansi "{dlgstring|Give this new File Collection a Name.}" /col import "dlgstring" {dlgopen|Pick a text File to Import into the New File Collection|*.txt}

Yes, with a variable.

@set TheNewFileCollection={dlgstring|Give this new File Collection a Name.}
"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /col create /ansi "{$TheNewFileCollection}" /col import "dlgstring" {dlgopen|Pick a text File to Import into the New File Collection|{$TheNewFileCollection}.txt}
1 Like

perfect! I love it!

thanks!!!

I had to move the lines around a little bit. /create and /import need their own lines.

heres the finished button, working like a dream... I cant be the only that will end up finding this useful.

Create and import into a file collection from a list of files.

@set TheNewFileCollection={dlgstring|Give This New File Collection a Name.}
"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /col create /ansi "{$TheNewFileCollection}"
"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /col import /ansi "{$TheNewFileCollection}" {dlgopen|Pick A Text File To Import Into "{$TheNewFileCollection}"|*.txt}

and quicker xml for pasting on a toolbar.

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>Create &amp;&amp; Import a File Collection</label>
	<tip>Create &amp; Import A File Collection From Text File Containing A List Of Files</tip>
	<icon1>#newcollection</icon1>
	<function type="normal">
		<instruction>@set TheNewFileCollection={dlgstring|Give This New File Collection a Name.}</instruction>
		<instruction>&quot;C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe&quot; /col create /ansi &quot;{$TheNewFileCollection}&quot;</instruction>
		<instruction>&quot;C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe&quot; /col import /ansi &quot;{$TheNewFileCollection}&quot; {dlgopen|Pick A Text File To Import Into &quot;{$TheNewFileCollection}&quot;|*.txt}</instruction>
		<instruction />
		<instruction />
		<instruction>// https://resource.dopus.com/t/find-and-copy-file-from-a-filelist-txt/52677/3</instruction>
	</function>
</button>


works with .txt files, one file per line, e.g.

C:\xsysicons\downloaded icons collection mixed\Save file floppy_48x48.ico
C:\xsysicons\Emoji Google Complete ico\save floppy goo_emoji_268_28x28.ico
C:\xsysicons\fatcow fugue icons mixed\color_picker__32x32.ico
C:\xsysicons\xxxPNG\hdr_Icon_Off144.png
C:\xsysicons\xxxPNG\hdr_Icon_On144.png
C:\Users\CLOUDEN\Documents\AutoHotkey\Lib\Images\appskey gui_1642x925.png
C:\Users\CLOUDEN\Documents\AutoHotKey\Lib\Images\autocorrect_icon_32x32.ico
C:\xsysicons\icons extracted from software\ShareX Icons\ruler-triangle_ShareX_16x16.ico
C:\xsysicons\icons extracted from software\ShareX Icons\ShareX_Icon_256x256.ico

Not necessarily. /create is also a flag for col /import and will create the collection if needed, e.g.

dopusrt /col import /create "{file}-{date|yyyyMMdd}-{time|HHmmss}" {filepath$}

ill keep playing with it. it makes sense that it should work in a slingle link, but maybe have the dialogue box popups were throwing it off? It would create a new collection with the input name. but wouldn't get the filelist.txt from the 2nd, the collection it was crating was empty

This works for me:

@set TheNewFileCollection={dlgstring|Give This New File Collection a Name.}
"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /col import /create /ansi "{$TheNewFileCollection}" {dlgopen|Pick A Text File To Import Into "{$TheNewFileCollection}"|*.txt}