Before we get into the tutorial, I will explain why I need to generate bulk Dropbox links. In this example, I am currently preparing an ArcGIS Project with a rock sample location layer in the project. This layer will have a pretty cool popup. Whenever the user clicks the sample location, it will display a popup with a photo of the rock sample. And the URL of the rock photos is saved in Dropbox. By doing this, we can share the layer with anyone and they will still be able to open the URL because it is available on the internet.
The problem is that there are hundreds of photos. It is almost impossible to enter the URL for each rock sample manually. I need some automated way to copy the Dropbox link or URL into my rock database. I am not a Python user so I will skip Python and Dropbox API. If you are in a similar situation, I think you can use my workaround below to generate bulk Dropbox links. We will utilize Microsoft Excel and a little code in Excel.
Step 1. Get the link for each file from Dropbox
First, we need to copy the link for the folder containing all the files/photos we want to copy.
Once we have copied the shared link, now open an Incognito browser. The idea was to open this link in a browser without a Dropbox login. If you are logged in, you will be having difficulties selecting all and copying the file name. Select all the files that we want to copy. See the example below.
Open Excel and then paste it into Excel. Please note that this will copy the file name as well as the image into Microsoft Excel. If you copy many files, it will take time to paste. See the example below. This is what it looks like after we paste the copied files from Dropbox into Excel.
Select and Deleted Images from Excel
What we need to do next, is to select all the images and then deleted them. Go to Home | Find & Select | Go To Special. Choose Objects and then press OK. This will select all the images in the spreadsheet.
Now you can delete all the images. Now we have the list of the files with hyperlinks on each file.
Extract the Hyperlinks
This is the fun part because now we want to extract the hyperlinks from the copied files. This method is really helpful when you need to generate hyperlinks from hundreds of files. We will create a new module in Microsoft Excel. This module will automatically detect any hyperlinks in the spreadsheet and extract them to a new column.
Copy the following script into the new module. I will show you how to do this in a moment.
Sub ExtractHL()
Dim HL As Hyperlink
For Each HL In ActiveSheet.Hyperlinks
HL.Range.Offset(0, 1).Value = HL.Address
Next
End Sub
How to create a new Module in Microsoft Excel
That’s it. Now I can use the hyperlinks to generate the picture preview in ArcGIS Pro. I will show you how to do this next time. Thanks for reading this article and see you next.
Tyler Hall
April 17, 2023Wrote a userscript to accomplish the same thing:
https://gist.github.com/tyhallcsu/89d6c672f93e94cbd651354b587306b4
Thank you, this guide helped me figure out the process, then I made the script 🙂
// ==UserScript==
// @name Extract All Dropbox Image URLs in Folder to Clipboard
// @namespace https://www.example.com/
// @version 3
// @description Extracts image URLs from a Dropbox page and copies them to the clipboard when a button is clicked.
// @author Tyler Hall Tech
// @match https://www.dropbox.com/*
// @grant GM_setClipboard
// @grant GM_log
// @run-at document-idle
// ==/UserScript==
(function() {
‘use strict’;
const SECONDS_TO_WAIT_FOR_SCROLL = 1; // adjust as needed
const DOWNLOAD_URL_REPLACEMENT = ‘?raw=1’;
// function to get all image link elements
function getImageLinks() {
const imageLinks = document.querySelectorAll(‘a.dig-Link.sl-link–file[href*=”dl=0″]’);
return Array.from(imageLinks).map(link => link.getAttribute(‘href’).replace(/\?dl=0$/, DOWNLOAD_URL_REPLACEMENT));
}
// function to scroll to the bottom of the page and wait for new images to load
async function waitForImagesToLoad() {
window.scrollTo(0, document.body.scrollHeight);
await new Promise(resolve => setTimeout(resolve, SECONDS_TO_WAIT_FOR_SCROLL * 1000));
}
// create an array to hold the image URLs
let imageUrls = [];
// add a button to the page that will copy the image URLs to the clipboard when clicked
const copyButton = document.createElement(‘button’);
copyButton.classList.add(‘dig-Button’, ‘dig-Button–primary’, ‘dig-Button–standard’, ‘copy-urls-button’);
copyButton.textContent = ‘Copy all URLs’;
copyButton.style.position = ‘fixed’;
copyButton.style.bottom = ’20px’;
copyButton.style.right = ’20px’;
copyButton.style.zIndex = ‘9999’;
document.body.appendChild(copyButton);
// add a click event listener to the button
copyButton.addEventListener(‘click’, async function() {
let finished = false;
let numUrls = 0;
while (!finished) {
// scroll to the bottom of the page and wait for new images to load
await waitForImagesToLoad();
// get the newly loaded image URLs
const newImageUrls = getImageLinks().filter(url => !imageUrls.includes(url));
imageUrls.push(…newImageUrls);
// check if all images have been loaded
finished = newImageUrls.length === 0;
numUrls += newImageUrls.length;
}
// join the image URLs into a string separated by newlines
const imageUrlString = imageUrls.join(‘\n’);
// copy the image URL string to the clipboard
GM_setClipboard(imageUrlString, ‘text’);
// disable the button and change the text to indicate that the URLs have been copied
copyButton.disabled = true;
copyButton.textContent = `${numUrls} URL(s) copied to clipboard`;
// enable the button again after 3 seconds
setTimeout(function() {
imageUrls = [];
copyButton.disabled = false;
copyButton.textContent = ‘Copy all URLs’;
}, 3000);
});
})();
admin
April 17, 2023Many thanks for this. I will try it.
Tyler Hall
June 16, 2023I have made it better:
https://greasyfork.org/en/scripts/465164-bulk-export-dropbox-image-urls-2023
Carsten
August 15, 2023This is amazing. Only issue for me is that my file names are sort of long, so when I view the Dropbox folder in Incognito, the file names are shortened with 3 dots in the middle of the file name (such as “thisfilenameissolongitgetscu….off.mp4”).
How can I get the full file name coped over? URL wise this method is AWESOME!