// This script automates the removal of all shared links from your Dropbox account. // Navigate to https://www.dropbox.com/share/links, open the browser console, and paste the JavaScript code below. // Optional: To delete only specific types of links (i.e., View or Edit links), // edit the `deleteLinkTexts` array to include only the types of links you want to remove. // By default, the script will target both "Delete view link" and "Delete edit link" options. // Script source: https://www.dropboxforum.com/t5/Create-upload-and-share/remove-all-shared-links/m-p/710562/highlight/true#M73731async function pause(ms) { return new Promise(resolve => { setTimeout(() => { resolve(); }, ms); }); } async function deleteLinks() { const deleteLinkTexts = ["Delete view link", "Delete edit link"];
// Both optionslet items = document.querySelectorAll('.share-page-row-actions [data-testid="open-menu-button"]'); for (let i = 0; i < items.length; i++) { items[i].click();
// Click the submenu button to open the menuawait pause(1000);
// Adjust the pause duration as needed// Find and click the appropriate delete link option const deleteLinkOption = Array.from(document.querySelectorAll('.dig-Menu-row-title')).find(item => deleteLinkTexts.includes(item.textContent)); if (deleteLinkOption) { deleteLinkOption.click();
// Click the delete link optionawait pause(1000);
// Adjust the pause duration as needed// Find and click the delete button const deleteButton = document.getElementsByClassName("dbmodal-button"); if (deleteButton.length > 0) { deleteButton[0].click(); await pause(1000);
// Adjust the pause duration as needed} } items = document.querySelectorAll('.share-page-row-actions [data-testid="open-menu-button"]');
// Refresh items} } deleteLinks();
List shared links:
% tbx dropbox file sharedlink list
...
| tag | url | name | expires | path_lower | visibility |
|--------|----------------------------|---------|---------|-----------------|------------|
| file | https://www.dropbox.com... | foo.jpg | | /photos/foo.jpg | public |
| file | https://www.dropbox.com... | bar.jpg | | /photos/bar.jpg | public |
| folder | https://www.dropbox.com... | Baz | | /baz | public |
The report generated: /Users/user/.toolbox/jobs/20240913-094617.OPY/report/shared_link.csv
The report generated: /Users/user/.toolbox/jobs/20240913-094617.OPY/report/shared_link.json
The report generated: /Users/user/.toolbox/jobs/20240913-094617.OPY/report/shared_link.xlsx
The command finished: 2.16s
Delete a single shared link:
% tbx dropbox file sharedlink delete -path /photos/foo.jpg
Removing link `https://www.dropbox.com...` that point to `/photos/foo.jpg`
| status | reason | input.tag | input.url | input.name | input.expires | input.path_lower | input.visibility | result |
|---------|--------|-----------|----------------------------|------------|---------------|------------------|------------------|--------|
| Success | | file | https://www.dropbox.com... | foo.jpg | | /photos/foo.jpg | public | |
...
or all shared links by extracting the paths from the path_lower
column in shared_link.csv with awk
and feeding them to tbx
via xargs
:
% awk -F ',' 'NR>1 {print $5}' shared_link.csv | xargs -I {} tbx dropbox file sharedlink delete -path "{}"
(tbx
includes a dropbox team sharedlink delete links
command to batch delete shared links for Teams accounts.)
From the How to manage your default sharing settings section of How to manage your Dropbox file and folder sharing permissions:
Log in to dropbox.com.
Click your avatar (profile picture or initials) in the top right.
Click Settings.
Click the Sharing tab.
Choose your default settings.
Use Who has access to manage who can open your shared links.
Anyone with the link: All the links you share are public. Anyone can open them.
Only people invited: Only people you invite can access your files and folders. If someone who wasn’t invited receives the link, they can’t open it.
Team members: Only other members on your team account can access your files and folders.
Use What people can do to manage whether people can edit the files and folders you share.
Can edit: Anyone who can open the shared link can edit the file.
Can view: Anyone who can open the shared link can view and comment on the file, but not edit it.
Note: These settings won’t apply when you share from a mobile device, or when you copy and paste a link from the address bar. The changes you make to default sharing settings won’t be applied to existing shared links. Only new links will use this setting.
/misc | Sep 14, 2024