TreePaste

A Windows tool that pastes copied files while preserving their folder structure. Choose the paste starting level from a tree view and paste from exactly where you need.

Overview

TreePaste is a desktop application for preserving source folder hierarchy when pasting files and folders copied in Explorer. Instead of a one-step paste, it visualizes copied items as a tree so you can choose the exact hierarchy level used as the paste starting point.

TreePaste main window showing folder hierarchy and paste level selection

The Problem It Solves

Explorer gives you exactly two outcomes when you paste. Copy a folder and you get the whole subtree including the folder itself. Copy the files inside it and you get a flat set of files with the structure gone. There is no way to say “keep the structure, but start it three levels down.”

Consider a report buried in a project tree:

D:\Projects\ClientA\2026\Reports\Q1\summary.xlsx
D:\Projects\ClientA\2026\Reports\Q1\appendix.xlsx
D:\Projects\ClientA\2026\Reports\Q2\summary.xlsx

If you want Reports\Q1\summary.xlsx to land in the destination — keeping the Reports and Q1 folders but dropping Projects, ClientA and 2026 — Explorer cannot do it in one step. The usual workaround is to paste everything and then delete the unwanted parent folders by hand, which is where mistakes happen.

TreePaste shows the copied items as a tree and lets you click the level that becomes the root of the paste. Select Reports and the destination receives Reports\Q1\summary.xlsx, with everything above it discarded.

Background

In real file management workflows, a normal paste often includes too many parent folders or loses structure that should remain intact. TreePaste was built to reduce these mistakes by making folder hierarchy visible before execution and letting you select where the paste begins.

The design goal was that the tool should never interrupt the flow of work. It stays in the tray rather than occupying a window, it is summoned by a global shortcut rather than by finding and clicking an icon, and it infers the destination from the Explorer window already in front of you rather than asking you to browse for it.

Key Features

How to Use

  1. Launch TreePaste (it stays in the system tray).
  2. Copy files or folders in Explorer (Ctrl+C).
  3. Open the destination folder in Explorer.
  4. Press Ctrl+Alt+V to open TreePaste.
  5. Select the paste starting point from the tree.
  6. Execute the paste.

Step 3 matters more than it looks: the destination is read from whichever Explorer window is in the foreground at the moment you press the shortcut. Bringing the target folder to the front before invoking TreePaste is what makes the destination correct.

How Destination Detection Works

Rather than asking the user to pick a destination folder, TreePaste reads it from the window you were just looking at. The lookup runs in three stages:

  1. Get the foreground window with GetForegroundWindow, then resolve its owning process via GetWindowThreadProcessId.
  2. If that process is explorer, enumerate the open shell windows through the Shell.Application COM object, match the one whose HWND equals the foreground window handle, and read its LocationURL to obtain the displayed folder path.
  3. If the foreground window is not an Explorer window — or the shell lookup yields nothing — fall back to the Desktop so the paste always has a valid target.

Matching on the window handle rather than simply taking the first shell window is what makes the behavior predictable when several Explorer windows are open at once: the destination is always the specific window that had focus, not an arbitrary one.

Notes and Known Behavior

System Requirements

Building from Source

With the .NET 10 SDK installed, build the solution directly:

dotnet build src/TreePaste/TreePaste.slnx

To produce a runnable build, publish for the win-x64 runtime in Release configuration. The output is written under src/publish/win-x64/.

Repository

Source code and usage details are available on GitHub.

View GitHub Repository - TreePaste