How to extract zip files in their grand-parent folder?

I have a large number of zip file, each one being in its own folder nested at the end of a folder hierarchy. That final folder, whilch holds only one zip file, is always named 'DATA'. The folder before last always has a unique name and holds only 'DATA'. To make it clear, the structure is something like

C:\PATH\FOLDER M\DATA\archive_n.zip

Two tasks:

I would like to move each archive_n to its corresponding FOLDER M and get rid of all the DATA folders.

I would then like to extract the content of each archive_n into the folder M holding it and, once this is done, get rid of all the archive_n files.

Ideas on how DO9 could help automate these tasks would be greatly appreciated. I am especially concerned about the first one, as a 3rd party application (ZipGhost) could accomplish the second one.

Thank you in advance for your guidance. W.

I assume you want to do this on Find Results, or from Flat View, where you need it to work with lots of selected files which are not all in the same folder.

(If not then it's a lot more simple.)

You can use this command to move all selected items into their respective parents:

Copy MOVE {filepath$} TO {filepath$|..\..}

So you could do a Find for *.zip below Data\ folders and then run that command on the results, for example.

This will move the files and then delete the Data folder:

@nofilenamequoting Copy MOVE "{filepath$}" TO "{filepath$|..\..}" Delete "{filepath$|..\..}\Data"

(Be careful not to run that in situations where the Data folder won't be empty. e.g. If you didn't select everything in the Data folder and ran that button, the Data folder and its contents would still be deleted.)

You could also extract straight into the parent folder, then delete the data folder:

@nofilenamequoting Copy "{filepath$}" EXTRACT TO "{filepath$|..\..}" Delete "{filepath$|..\..}\Data"
That does everything you want in one click. However, you should be careful if you use that button: If the zip file contains a Data directory then it will be extracted and then deleted, of course.