Jump to content

Google Drive File Interactions

Recommended Posts

Good Morning, I am writing on a whim here so no rush or urgency, I just have always had great success bringing my ideas to the table here and seeing what others think.


I run a web hosting / design company, and use Alfred every day all day for many of my tasks. One of my organizational techniques is Google Drive with a huge client folder structure where each client has a folder  (last name, first name - Company name) and then inside each folder I have sub folder (files, notes, etc) and even a password doc that gets changed for each client (Passwords for Last Name, First Name - Company name)  and the same with general information.


I tell you all of this so you can see how it connects with alfred. I then use the a Drive workflow from this forum to query the drive for the files im looking for quickly. IE: Open Alred >> D passwords for clients name shows me that document and I can open right there.


First thing I want to know, and I know this is a long shot. Any way to make it show the contents of that doc in alfred (I would imagine it couldnt pull the data, but just wanted to throw it out there0


Then my main question. Is there any way I can use this same type of flow, (make a google docs file called Notes for Client Name) and be able to add content to it straight from alfred. It would be extremely helpful to have a way to add a quick 1 line note to a clients files for when we make changes that need to be documented or time lined. So I would say Open Afred >> Notes for client name >> Made changes to adword account 8/24/2018, and that would be written write into that notes file I created, and every time I did that it would just be added to a new line (could be a spreadsheet)


Any thoughts, I know its a long shot but ive seen that great workflow I sheet you not that interacts with sheets.


Thank you for any suggestions!

Link to comment
4 hours ago, ixium said:

Any way to make it show the contents of that doc in alfred


Yes. Assuming you're talking about Google Sheets, you can use the Google API to download them as Excel files and then plug them into I Sheet You Not.


Obviously, it requires some coding (mostly the OAuth stuff), but it's a lot simpler than building the whole thing.


Link to comment

I havent had any luck with this as I know its pretty complicated. I do have one more question for you if you dont mind (and thank you so much for all the help you have provided throughout the years!)


The script I wrote about above is a google script and only requires one thing to be changed, the name field, which propogates all the documents with the right names.


What im wondering is, is there any way to trigger this script from within alfred and pass the one variable I need to the script.


Right now I have to open the script (which I do with an alfred shortcut) change the varialbe I need and then run it, Im just wondering if I can hotkey open alfred, type the name and hit enter to run the script.


Just not sure if Alfred can interact with google that way.


Thank you so much!

Link to comment
1 hour ago, ixium said:

What im wondering is, is there any way to trigger this script from within alfred and pass the one variable I need to the script.


That should be trivially easy. Can't say more because we're talking about a script I've never seen…

Link to comment
13 minutes ago, ixium said:

Ok to add script here? It references files but I dont think anyone could access them without being in my account right?


Post the script here unless it's really long. As long as there aren't any login credentials/API keys in it, it should be fine.

Link to comment

Awesome, thank you, this is written in googles script editor, I have no idea how to get it to link back to my alfred, thank you


function newClient() {
 var clientName = ('Last Name, First Name - Company Name');
 var clientFolder = DriveApp.createFolder(clientName);
 var masterClientFolder = DriveApp.getFolderById("0B2Xyh0kSszIcYXJtemlSSUNlYUE"); 
 var clientFilesFolder = DriveApp.createFolder('Files');
  var clientNotesFolder = DriveApp.createFolder('Notes');
  var clientReportsFolder = DriveApp.createFolder('Reports');
  //add new folders to new client folder and remove extra root drive folders
var ss = SpreadsheetApp.openById("1BEcSVNy2esknAtcKc5-W_cV-PQy0yJAKt4rdLizrgNc");
var newSS = ss.copy(ss.getName () + " for " + (clientName));
// Move to original folder
var newSSFile = DriveApp.getFileById(newSS.getId());
  var ss2 = SpreadsheetApp.openById("1uIbex2ACiIa8AINjivwfLQldQSvMqMZ-Hyl1msbj8Tg");
var newSS2 = ss2.copy(ss2.getName () + " for " + (clientName));
// Move to original folder
var newSS2File = DriveApp.getFileById(newSS2.getId());
var ss3 = SpreadsheetApp.openById("1rbyaBq5dQuYMwOtv1isZg0Bf2OHY3W3eaL4zP_wayhY");
var newSS3 = ss3.copy(ss3.getName () + " for " + (clientName));
// Move to original folder
var newSS3File = DriveApp.getFileById(newSS3.getId());

So its just taking my input of name (Last name, first name - Company) and making copies of files I have in a template folder. So all I need to do is be able to run this script from within alfred and have it pass the argument to the var ClientName


Thank you so much for looking at this

Link to comment
1 minute ago, ixium said:

this is written in googles script editor


In that case, I haven't got a clue. I thought you were talking about a command-line script, not one buried somewhere in their web service.


Unless you can pass parameters to a script via the Google Drive URL (which a quick Googling says isn't possible), I don't think there's any way around using Google's APIs (and their OAuth authentication) to connect Alfred to Google Drive.


Perhaps there's some existing tool that can manipulate GD documents that you can plug into Alfred?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...