Skip to main content

Place several files on clipboard from the command-line

Project description

clipboard-many-files

@readwithai - X - blog - machine-assisted reading

A command-line tool to copy several files to the clipboard as though you copied them from a file browser.

At present, this tool only supports Linux (both X11 and wayland). This tool requires xclip if you are using X11 or wl-clipboard if you are using Wayland.

Motivation

You can copy and paste multiple images from file browsers such as Dolphin in KDE to many applications such as wordprocessors and browsers. It is useful to be able to do this from the command-line and within scripts

I could not find any command-line tools to this, despite it being fairly straight-forward when you understand the protocol used. I decided to implement this in a standard way and share it in an easy-to-use form.

Alternatives and prior work

Most file browsers support copy-and-pasting multiple files.

It is fairly straightforward to do this manually by setting the text/uri-list target in the clipboard to a new-line separated list of entries file URL scheme. Any user familiar with bash could create a shell script on their path to do so. This tool, however, removes the need to maintain such as script, and can easily be installed on any system.

Attribution

I made use of this approach of converting paths to URLs.

When reviewing clipbaord libraries, I found some of the code of pyperclip informative for implementing wayland functionality.

Installation

You can install clipboard-many-files using pipx:

pipx install clipboard-many-files

Usage

Two executables are provides clipboard-many-files and cmf. These do the same thing.

To place files on the clipboard you can run.

cmf file1.ext file2.ext

You can wish to use a global to place multiple files on the clipboard:

cmd *.png

Caveats

I wrote and tested this tool on Linux and this is the only operating system supported at the moment. Patches adding support to other operating systems are much appreciated and will be quickly merged.

I use a couple of command-line tools to access the clipboard. I could find no python library which supported setting targets and reading the code for xclip communicating with X11 directly is probably more effort that this involved. Klembord seems to have this option - but has been archived and when I tested this functionality on X11 it did not work.

Support

If you found this tool useful, you could give me $1 on my ko-fi. This will incentivize me to respond to issues with this project and create similar tools.

You can also support this project by looking at similar tools that I have created or reviewing my work related to reading and research.

About me

I am @readwithai. I create tools for reading, research and agency, sometimes using Obsidian.

I also tend to produce a stream of tools related to my work.

I post about both on X. I write more about reading and research on my blog.

@readwithai logo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clipboard_many_files-1.0.3.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file clipboard_many_files-1.0.3.tar.gz.

File metadata

  • Download URL: clipboard_many_files-1.0.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for clipboard_many_files-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e8e96cd74f48a63f2f41c6f016f246e440c84a3a8ef2e8c22d8354c6c0a9f555
MD5 62a0688866b6d4f58994600498e7db34
BLAKE2b-256 296c8c065618f4073dd497fe57594d31a0107e47e9c7747d60c4d72f66fb2942

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page