Reputation: 51
I've been working with Google Drive's features for a while now,but I've stumbled on quite a problematic issue.
As people know,you can get multiple share links from multiple files within Google Drive,by holding the Shift button+selecting the files,and then right clicking and select 'Share' and 'Get Link'
However the problem is,that the links I get are in a completely random order!,I've been checking over and over if they were sorted by date or filename or access time,but I couldn't figure out any reasoning behind the seemingly random order.
This is quite a nuisance as I was trying to use Google Drive as an alternative to Google Photos to get direct links to multiple images without having to manually get the link for each image.
Is there a way to get multiple links in Google Drive,by actual file order?(e.g. sorted by filename)
Upvotes: 2
Views: 10141
Reputation:
My solution is to create a Spreadsheet Appscript.
function linksBulk() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var s=ss.getActiveSheet();
var c=s.getActiveCell();
var fldr=DriveApp.getFolderById("PUT YOUR ID FOLDER HERE PLS");
var files=fldr.getFiles();
var names=[],f,str;
while (files.hasNext()) {
f=files.next();
str='=hyperlink("' + f.getUrl() + '","' + f.getName() + '")';
names.push([str]);
}
s.getRange(c.getRow(),c.getColumn(),names.length).setFormulas(names);
}
function linkURL(reference) {
var sheet = SpreadsheetApp.getActiveSheet();
var formula = SpreadsheetApp.getActiveRange().getFormula();
var args = formula.match(/=\w+\((.*)\)/i);
try {
var range = sheet.getRange(args[1]);
}
catch(e) {
throw new Error(args[1] + ' is not a valid range');
}
var formulas = range.getFormulas();
var output = [];
for (var i = 0; i < formulas.length; i++) {
var row = [];
for (var j = 0; j < formulas[0].length; j++) {
var url = formulas[i][j].match(/=hyperlink\("([^"]+)"/i);
row.push(url ? url[1] : '');
}
output.push(row);
}
return output
}
Upvotes: 0
Reputation: 51
I found a"sort of"solution which is not really straightforward but I guess it's better than nothing.
First, you need to have JDownloader installed, it's a small downloader manager program (which is pretty useful when you're downloading large Google Drive files and your internet is so slow you can't finish it in one session), then....
I know this is pretty cumbersome process but I really couldn't find a better solution, still open for better solutions tho!
Upvotes: 3
Reputation: 11
I found a solution. 1) Install app for google drive - 'Bulk Share URL Shortener with Google Drive' 2) Order your files as you need 3) Select all files you need to copy shared links 4) Right click on the selected area 5) Open with.. - Bulk Shared URL..
In the new window, you will see a list of links in the order you set.
Upvotes: -1
Reputation: 116968
There are no sorting options for the Google drive API requests. You will need to sort the information locally after you have retrieved the full request.
Note: This isn't the first time I have seen this question an idea would be to send in a feature request. Google Drive Issue Forum if you decided to do that make sure you are clear give examples of what you want and why you think they should add it. I tend to get better results that way
Upvotes: 2