A lightweight Windows context menu tool that generates public links to files and folders in Nextcloud with a single right-click.
- One-click integration - Generate Nextcloud public links directly from Windows Explorer
- Simple configuration - All settings in one place at the top of the script
- Flexible path mapping - Convert any local path to Nextcloud path with regex patterns
- Robust error handling - Automatic retry mechanism with detailed feedback
- Clean interface - Color-coded output for better readability
- Instant clipboard copy - Links automatically copied and ready to paste
- Battle-tested - Successfully tested with real Nextcloud instances
- Windows 10/11 with PowerShell 5.1+
curl.exe(included in Windows 10/11)- Nextcloud server with API access
- Administrator rights for registry installation
For the best terminal experience, we recommend using PowerShell 7:
- Download from GitHub
- Better UTF-8 character support
- Enhanced display and performance
If using Windows PowerShell 5.1, the script works perfectly but some display characters may render differently.
- Download the latest release or clone this repository
- Edit
src/ExportNextcloudLink.ps1and modify the configuration section:
# CONFIGURATION SECTION - MODIFY THESE VALUES
$NEXTCLOUD_SERVER = "https://your-nextcloud-server.com" # Your Nextcloud URL
$NEXTCLOUD_USERNAME = "your-username" # Your username
$NEXTCLOUD_PASSWORD = "your-password" # Your password
# Path mappings - Local to Nextcloud path conversion
$PATH_MAPPINGS = @(
@{ Pattern = "^C:\\Users\\YourName\\Documents"; Replacement = "/Documents" },
@{ Pattern = "^D:\\Projects"; Replacement = "/Projects" },
@{ Pattern = "^C:\\"; Replacement = "/LocalDrive" }
)-
Edit
install/context_menu.reg- update the path to your script location:@="pwsh -NoProfile -ExecutionPolicy Bypass -File \"C:\\your\\path\\ExportNextcloudLink.ps1\" -FilePath \"%1\"" -
Run as Administrator and execute:
regedit /s install/context_menu.reg
- Right-click any file or folder in Windows Explorer
- Select "Generate Nextcloud Link"
- Wait for the script to process
- Paste the link anywhere - it's already in your clipboard!
- Right-click any file or folder β "Generate Nextcloud Link"
- Link automatically copied to clipboard
Run the script directly with a file path:
# PowerShell
pwsh -NoProfile -ExecutionPolicy Bypass -File "C:\path\to\ExportNextcloudLink.ps1" -FilePath "C:\your\file.txt"
# Command Prompt
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\path\to\ExportNextcloudLink.ps1" -FilePath "D:\Projects\app\main.js"Examples:
# Single file
.\ExportNextcloudLink.ps1 -FilePath "C:\Documents\report.pdf"
# Folder
.\ExportNextcloudLink.ps1 -FilePath "D:\Projects\MyApp"
# Network path
.\ExportNextcloudLink.ps1 -FilePath "\\server\share\document.docx"nextcloud-link-generator/
βββ src/
β βββ ExportNextcloudLink.ps1 # Main script with configuration
βββ install/
β βββ context_menu.reg # Registry entries for right-click menu
βββ docs/
β βββ CONFIGURATION.md # Advanced configuration guide
β βββ TROUBLESHOOTING.md # Common issues and solutions
βββ README.md # This file
Path mappings convert your local Windows paths to Nextcloud paths using regex patterns:
$PATH_MAPPINGS = @(
# Map entire drives
@{ Pattern = "^C:\\"; Replacement = "/LocalC" },
@{ Pattern = "^D:\\"; Replacement = "/LocalD" },
# Map specific folders
@{ Pattern = "^C:\\Users\\John\\Documents"; Replacement = "/JohnDocs" },
@{ Pattern = "^C:\\Projects"; Replacement = "/Work" },
# Map network drives
@{ Pattern = "^\\\\server\\share"; Replacement = "/NetworkShare" },
# Catch-all for unmapped drives (put this last)
@{ Pattern = "^[A-Z]:\\"; Replacement = "/OtherDrives" }
)| Local Path | Pattern | Replacement | Result |
|---|---|---|---|
C:\Users\John\file.txt |
^C:\\Users\\John |
/JohnHome |
/JohnHome/file.txt |
D:\Projects\app\src\main.js |
^D:\\Projects |
/Work |
/Work/app/src/main.js |
\\server\docs\report.pdf |
^\\\\server\\docs |
/SharedDocs |
/SharedDocs/report.pdf |
Enable detailed logging by setting:
$DEBUG = $trueThis will show:
- Path mapping process
- Curl commands (with hidden passwords)
- Server responses
- Retry attempts
When you run the script, you'll see:
NEXTCLOUD LINK GENERATOR
=========================
Processing file...
Generating link...
-------------------------------------------------------------
Link copied to clipboard:
https://your-nextcloud.com/s/abc123xyz
-------------------------------------------------------------
"Please configure NEXTCLOUD_SERVER"
- Edit the script and set your Nextcloud server URL
"No path mapping found"
- Add appropriate path mappings for your directory structure
- Use Windows path format with double backslashes in patterns
"Failed to generate public URL"
- Check your Nextcloud credentials
- Verify the file/folder exists in Nextcloud
- Enable debug mode for detailed error info
Context menu doesn't appear
- Ensure you ran
regeditas Administrator - Check the script path in the .reg file is correct
- Try logging out and back in to Windows
- Enable debug mode (
$DEBUG = $true) - Check the generated
curl_output.txtfile - Verify your Nextcloud server is accessible
- Test credentials in a web browser first
- Store credentials securely - consider using Windows Credential Manager
- Use app-specific passwords when available
- Don't commit your configured script with real credentials
- The script hides passwords in debug output
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
If this tool helps you, please give it a star on GitHub!
Made with β€οΈ for seamless Nextcloud sharing