π Copy and read file paths and text from clipboard - A cross platform utility.
This library provides functionality for copying and reading file paths and text from the clipboard in Electron applications. It supports Windows, macOS, and Linux platforms.
Built with napi-rs and Rust, this library offers:
- Multiple file path support: Copy and read multiple file paths at once
- Text support: Read text from the clipboard
- Full TypeScript support
- Cross-platform compatibility
When developing Electron applications, I needed a way to copy multiple photo file paths to the clipboard at once and read content from the clipboard. This library was created to provide a simple solution for batch file path operations, making photo management and other tasks more efficient.
npm install clip-filepathsimport { writeClipboardFilePaths } from 'clip-filepaths';
// Copy file paths to clipboard
const filePaths: string[] = ['/path/to/file1.txt', '/path/to/file2.jpg'];
writeClipboardFilePaths(filePaths);
console.log('File paths copied to clipboard successfully');import { readClipboardFilePaths } from 'clip-filepaths';
// Read both file paths and text from clipboard
const content = readClipboardFilePaths();
console.log('File paths:', content.filePaths);
console.log('Text:', content.text);
// Check if clipboard has file paths
if (content.filePaths.length > 0) {
console.log('Clipboard contains file paths');
}
// Check if clipboard has text
if (content.text) {
console.log('Clipboard contains text');
}import { writeClipboardFilePaths } from 'clip-filepaths';
// Clear clipboard content by passing an empty array
writeClipboardFilePaths([]);A demo application is available for testing the functionality. If you want to see it in action, check out the following repository:
- copy-file-paths-electron - Demo Electron application
- β macOS: Supported and tested
- β Windows: Supported and tested
β οΈ Linux: Supported but not yet tested
We welcome contributions! Please read our Contributing Guidelines before submitting pull requests.
If you encounter any issues or have questions, please:
- Check the existing issues
- Create a new issue if your problem hasn't been reported
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to all contributors who have helped improve this project
- Special thanks to the napi-rs team for their excellent framework