Skip to content

Lightweight Windows context menu tool for generating Nextcloud public links

License

Notifications You must be signed in to change notification settings

szymontex/nextcloud-link-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nextcloud Link Generator

A lightweight Windows context menu tool that generates public links to files and folders in Nextcloud with a single right-click.

πŸš€ Features

  • 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

πŸ“‹ Prerequisites

  • Windows 10/11 with PowerShell 5.1+
  • curl.exe (included in Windows 10/11)
  • Nextcloud server with API access
  • Administrator rights for registry installation

Recommended: PowerShell 7

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.

πŸ› οΈ Quick Setup

1. Download and Configure

  1. Download the latest release or clone this repository
  2. Edit src/ExportNextcloudLink.ps1 and 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" }
)

2. Install Context Menu

  1. Edit install/context_menu.reg - update the path to your script location:

    @="pwsh -NoProfile -ExecutionPolicy Bypass -File \"C:\\your\\path\\ExportNextcloudLink.ps1\" -FilePath \"%1\""
    
  2. Run as Administrator and execute:

    regedit /s install/context_menu.reg

3. Test It Out

  1. Right-click any file or folder in Windows Explorer
  2. Select "Generate Nextcloud Link"
  3. Wait for the script to process
  4. Paste the link anywhere - it's already in your clipboard!

πŸ”§ Usage

Context Menu (Recommended)

  • Right-click any file or folder β†’ "Generate Nextcloud Link"
  • Link automatically copied to clipboard

Command Line

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"

πŸ“ Project Structure

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

βš™οΈ Configuration Guide

Path Mappings Explained

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" }
)

Common Examples

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

Debug Mode

Enable detailed logging by setting:

$DEBUG = $true

This will show:

  • Path mapping process
  • Curl commands (with hidden passwords)
  • Server responses
  • Retry attempts

🎨 What You'll See

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
-------------------------------------------------------------

πŸ› Troubleshooting

Common Issues

"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 regedit as Administrator
  • Check the script path in the .reg file is correct
  • Try logging out and back in to Windows

Getting Help

  1. Enable debug mode ($DEBUG = $true)
  2. Check the generated curl_output.txt file
  3. Verify your Nextcloud server is accessible
  4. Test credentials in a web browser first

πŸ”’ Security Notes

  • 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

πŸ“„ License

MIT License - see LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

⭐ Star This Project

If this tool helps you, please give it a star on GitHub!


Made with ❀️ for seamless Nextcloud sharing

About

Lightweight Windows context menu tool for generating Nextcloud public links

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published