Dropbox should provide a keyboard command to quickly get a link in Finder for a file in the Dropbox folder. Sadly, despite years of requests, this still isn't possible.
So I wrote this script to do that. Read more about it on the Dropbox Forum.
The script uses threads to send up to 10 link requests at a time, so it should be quite speedy, especially if you can batch your requests.
$ get_dropbox_link.py ~/Dropbox/file*
https://www.dropbox.com/s/xxxx/file%20to%20share.txt?dl=0
https://www.dropbox.com/s/xxxx/file2.jpg?dl=0
There are a couple of arguments available to change the returned URLs, which can be used independently:
$ get_dropbox_link.py ~/Dropbox/file* --plus-for-space --query raw=1
https://www.dropbox.com/s/xxxx/file+to+share.txt?dl=0&raw=1
https://www.dropbox.com/s/xxxx/file2.jpg?dl=0&raw=1
Note that you can remove an argument from the returned Dropbox link by marking it as empty:
$ get_dropbox_link.py ~/Dropbox/file2.jpg --query 'raw=1&dl='
https://www.dropbox.com/s/xxxx/file2.jpg?raw=1
-
Place the
get_dropbox_link.py
script somewhere in yourPATH
. The rest of these instructions assume you've placed it in$HOME/bin
. -
Set the script's permissions so you can run it:
chmod +x ~/bin/get_dropbox_link.py
-
Install the dropbox Python SDK. You may also need to pin urllib3 to an earlier version. (See issue #6 for more.)
/usr/bin/python3 -m pip install dropbox /usr/bin/python3 -m pip install urllib3==1.26.6
-
Give the app an access type of Full Access.
-
Create it.
-
Change the Permissions settings to have a scope of
sharing.write
.
- Copy the App Key:
-
Call the script once and follow the instructions to get a refresh token the first time:
$ get_dropbox_link.py ~/Dropbox/Public/cat.jpg => Please provide your app's App Key. This is NOT an OAuth2 token. Find the App Key in the App Console. See the README. App Key: aaaaaaaaaaaaaaa => Which kind of Dropbox account is this App Key associated with? [p]ersonal or [b]usiness? p => Refresh token not found. Let's generate a new one. 1. Go to: https://www.dropbox.com/oauth2/authorize?xxxx 2. Click "Allow", etc. (You may need to log in first.) 3. Copy the Access Code. Enter the Access Code here: xxxx https://www.dropbox.com/s/xxxx/cat.jpg?dl=0
Now you can continue calling it to generate links.
$ get_dropbox_link.py ~/Dropbox/file.txt ~/Dropbox/file2.txt https://www.dropbox.com/s/xxxx/file.txt?dl=0 https://www.dropbox.com/s/xxxx/file2.txt?dl=0 $
My goal was to have a keyboard shortcut in Finder that would copy a Dropbox link to the clipboard. If you want to do that too, you'll need to add an Automator Quick Action. Choose one of these options:
-
In your local copy of this repo, double-click the "Get Dropbox Link" workflow.
-
Press Install.
-
There's no step 3.
Warning
If you have installed the script somewhere other than
~/bin/get_dropbox_link.py
, you will need to edit the workflow to point at your custom location. You can find it in ~/Library/Services.
-
Open Automator and create a new Quick Action.
-
Find and drag over two actions: Run Shell Script, and Copy to Clipboard.
-
In the Run Shell Script action, give it the content of:
$HOME/bin/get_dropbox_link.py "$@"
Warning
Make sure you set the workflow to receive the current files or folders from Finder. Also, change the popup button to Pass input as arguments.
Warning
Make sure the path here is the same as the path that you saved the script to earlier!
-
Save the Quick Action to the default location (~/Library/Services). Give it the name you want it to have in the menu, like "Get Dropbox Link".
-
Once you're done, the action should look like this:
Note
Please note that pressing "Run" within Automator will complain about missing the
paths
argument. This is correct, and happens because Automator doesn't have any selected Finder items to pass into the workflow. Instead, you need to hook up the shortcut below and use the workflow as a Quick Action from Finder via the Services menu. Learn more at AskDifferent and Apple Support.
Now that you have the script and workflow installed, the last piece is the Finder shortcut.
- Open System Preferences > Keyboard > Shortcuts and navigate to Services. In the outline view, under "Files and Folders", locate the "Get Dropbox Link" service.
- Make sure the checkbox to the left is checked, and give it a shortcut. Here, I've chosen Cmd+Ctrl+L.
- Now, you can test it! Go to your Dropbox folder in Finder. Select at least one file and press Cmd+Ctrl+L. Your clipboard should now contain the links to the files. Note that when creating multiple links, each link has to be requested individually, so there may be a delay before the links appear on your clipboard. Watch for the spinning Automator gear in your menu bar.