Jump to content

Trying to Modify URL in Clipboard

Recommended Posts

I'm relatively new to automation, but I have a few situations where this action would be very useful. I'm just not sure where to start.


I want to take my clipboard contents and extract a string from a known point and drop it in the middle of a different known string then either write that to the clipboard or expand it like a snippet.


In one instance, I want to pull the document ID for a Google Drive document (I'm uploading via transmit, I don't want to install Google Drive locally) and put it in the middle of a sharing URL.




I want to put the 1Dw.... in place of the xxx


Thanks in advance, any advice is appreciated!

Link to comment

If the input is always in that format, one way to do it that might also give you some ideas for general use would be the Argument and Variables UtilityReplace Utility




  • The input is keyword with No Argument.
  • The Argument and Variables Utility with {clipboard} as the argument passes the text string from the clipboard to the Replace Utility
  • Replace Utility is set to regex, with an expression that groups the text string received from the previous object into three groups:
    • Group 1) "https://drive.google.com/uc?id="
    • Group 2) whatever is in between Groups 1 and 3 (in this case "1DwOwtpOX-tVb5xd7kws7y1oTZQCJtUtF")
    • Group 3) "&export=download"
    • Then replaces them with "https://drive.google.com/file/d/" + Group 2 ("1DwOwtpOX-tVb5xd7kws7y1oTZQCJtUtF") + "?usp=sharing" as the new string with gets sent as {query} to the next workflow object.
    • From there you can output it back to the clipboard, ready to paste. My screenshot shows Large Type for output just so I could see it and compare to yours.
    • The values in the Replace Utility are Replace regex (https:\/\/drive\.google\.com\/uc\?id=)(.*?)(&export=download) with https://drive.google.com/file/d/$2/view?usp=sharing 
  • If you want to avoid regex, you can use two Replace Utility objects:




There may be prettier ways to do it, but I thought this might be helpful to see how some of these objects can be strung together.


Edited by deanishe
remove screenshot ;)
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...