Copying folders without subfolders

Hello

Before get started, I'm not a english so please understand if I say something stupid.

I'm wondering how to copy only folders, excluding subfolders. I mean only folders I selected without it's contents.

I've tried a few filter.


Wrong.


Because every folder and it's contents which I tried to copy is created within a couple of months,

I thought using that filter could works. Turns out no. Nothing happen, didn't copied any folder or file.


those name nigrhianei;gninfei, It's nothing. Just random word, because there is no such folder.

Didn't works too.

I thought [name, no match, nieageinge] would include every subfolders, and [subfolder, no match] would reverse that resulting in none.

Well, I've been searching, I have found these.

Yeap. There is a solution. I'm just confused why those filter doesn't work.

PS. the first clause of a picture. I learned it from the link. Thank you very much.

The filters don't work because they exclude the folders you're trying to copy themselves.

I don't get it. subfolder includes the folder i try to copy?

If you are in a folder, and select a sub-folder, and then use a filter that excludes all sub-folders (like subfolder-nomatch-*), then it will be skipped.

I think that is what is happening.

Let me know if I understand correctly. When i select a folder and copy it, is selected folder itself regarded as subfolder?

Let's say I have a folder 't', and it has subfolders of '1', '2', '3'

I want to copy folder 't', but not subfolders, which are '1', '2', '3'

So i select folder 't', copy it with the first filter. Then folder 't' itself is regarded as subfolder? Hence nothing is copied?

If so, how can I do this?

If you mean you want to copy all the files in folder "t" but none of the folders, then I suggest:

  1. Download this button, On-Off Only Files Toggle.dcf (918 Bytes)

The code is:

@toggle:disable
Set QUICKFILTERFLAGS=clear
@if:$tab:ONLY
@set tab:ONLY
Set QUICKFILTERFLAGS=clear
@if:else
Set QUICKFILTERFLAGS=set,hidedirs
@set tab:ONLY=on
@if:common
@toggle:update
  1. Put the button in a toolbar
  2. Go to folder "t"
  3. Click the button to see only files
  4. Select all the files
  5. Copy them

Many alternate ways exist to do this.

@jinsight
Thank you for reply. What i'm trying to do is actually copy folder 't' without any of contents of it. Neither files nor subfolders.

Only folder 't'. Not any other things.
You might wonder why not create a folder with same name, then?

The reason for that is i want to copy a folder with timestamp.

If you just folder names and structure, try this:

  1. Create a Find filter called "All folders"

  2. A button,
    Create an Empty Folder Structure.dcf (449 Bytes)
    with this code:

//Requires a filter searching for only folders labelled "All Folders"
Copy FILTER="All Folders"
  1. Selected the folder "t" in the source
  2. Run the button
  3. The destination will have you folder "t" with the same time stamp and all its subfolders with no contents

Hey, just my two cents here, you can try this script. It will create new folders with the same names as those you have selected, so any subfolder or file will be copied, and then transfer the creation and modification dates to those new folders. If you're using a two-view lister, it will transfer the folders from the source to the destination, and if you're using a single-view lister, it will prompt you for a specific path to make the copy.

function OnClick(clickData) {
    var sourceTab = clickData.func.sourcetab;
    var destTab = clickData.func.desttab;
    var cmd = clickData.func.command;
    cmd.deselect = false; // Do not deselect items after running the command

    var fsUtil = DOpus.FSUtil();

    // If no destination, prompt the user for a directory
    if (!destTab) {
        var dlg = clickData.func.Dlg;
        dlg.title = "Select Directory";
        dlg.message = "Please select the directory where you want to copy the selected folders:";
        dlg.buttons = "OK|Cancel";
        dlg.defvalue = "";
        dlg.max = 255;

        var result = dlg.Show();

        if (result === 2) { // If the user clicks "Cancel"
            return;
        }

        var destPath = dlg.input; // Get the input directory
        if (!fsUtil.Exists(destPath)) {
            DOpus.Output("The entered directory does not exist.");
            return;
        }

        destTab = { path: fsUtil.Resolve(destPath) }; // Create a simulated destination object
    }

    var selectedFolders = new Enumerator(sourceTab.selected_dirs);

    while (!selectedFolders.atEnd()) {
        var folderItem = selectedFolders.item();
        var sourcePath = folderItem.realpath;
        var destPath = fsUtil.Resolve(destTab.path + "\\" + folderItem.name);

        // Create the folder in the destination
        cmd.RunCommand('CreateFolder NAME="' + destPath + '"');

        // Format the dates as required
        var creationDate = folderItem.create.Format("D#yyyy-MM-dd T#HH:mm:ss");
        var modificationDate = folderItem.modify.Format("D#yyyy-MM-dd T#HH:mm:ss");

        // Set the dates on the destination folder
        var setAttrCommand = 'SetAttr FILE="' + destPath + '" CREATED="' + creationDate + '" MODIFIED="' + modificationDate + '"';
        cmd.RunCommand(setAttrCommand);

        selectedFolders.moveNext();
    }
}