Scan folders and copy/move a directory if it exists

Hello :slight_smile:

The situation :
I have a large amount of folders that contains unuseful files in a directory named "archives".
I would like to scan all of these folders, and if "archives" exists, i want to move all the folders and files in it, elsewhere.

For example, if i have :
C:\myfiles\folder1\archives (with files and folders in it)
C:\myfiles\folder2\archives (with files and folders in it)

I want to move them to :
D:\archives of myfiles\folder1 (with all files and folders that were in the archive)
D:\archives of myfiles\folder2 (with all files and folders that were in the archive)

Can you help me ??

Thanks for any help :slight_smile:

Mykael

PS :
I tried to use the flat view to have all the "archives" folders grouped, but i use a too large amount of folders, the result of the flat view is a random result, with just a few of the folders selected, "flatted"...
let me know if you meet this problem too, and i will probably open a new thread for that :slight_smile:

PS2 :
I read my post before submiting, and i wonder if i am understandable ??

You can use a copy filter to only copy files which are below an "archives" folder.

The filter to use would probably be this:

Location, Match, *\archives(|*)
[x] Use wildcards


What that won't get you is changing the names of the folders and re-arranging the order that the parent folder names come in. I don't think there is a good way to do that as part of the copy.

Well,
The problem is that i don't want to have in the destination, my files in a "archives" folder, but in a folder named as the folder selected in the source (archives's parent folder).

If i have in the source, the folder "C:\myfiles\folder1" selected,
I want to move the files (and folders) in "C:\myfiles\folder1\archives" to "D:\archives of myfiles\folder1" (not in "archives" folder).

So i tried this code :

COPY "{filepath}\archives" TO "D:\archives of myfiles\{filepath|noroot}"

Any idea??

Oh, and another question !
When i make my own buttons, i never know how to display the value of a variable, to debug and understand what happens :slight_smile: Ex : @set dir$={filepath|noroot}
Is it possible to display a variable value in a dialog box, or in DOS with an "echo", or in any other way ??

Try this (added "noterm" in the first part, and changed from TO to CREATEFOLDER so that it should work if the folder does not already exist):

COPY "{filepath|noterm}\archives" CREATEFOLDER "D:\archives of myfiles\{filepath|noroot}"

If you want Opus to show a message box, you can use dopusrt /ArgsMsgBox like this. It will display whatever text you give it, so you can use it to see the command line which would be run:

dopusrt /ArgsMsgBox COPY "{filepath|noterm}\archives" CREATEFOLDER "D:\archives of myfiles\{filepath|noroot}"


(You can also use the DOS echo command when writing MS-DOS Batch buttons, of course.)

Hello again :slight_smile:

The problem was that the folder "archives" was created, and i didn't want that.
I didn't want to use all the path too, just the name of the folder (folder1 in my example).

So ! Finally i did this, and it works like a charm :slight_smile:

COPY "{filepath|noterm}\archives\*.*" CREATEFOLDER "D:\archives of myfiles\{filepath|noroot|nopath}"

Thanks for your help, and now i can't live without DopusRT /ArgsMsgBox :wink: