OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Automation to Convert Mac to Windows Paths

  • Thread starter Thread starter Francisco Chaves
  • Start date Start date
F

Francisco Chaves

Guest
I'm migrating to MacOS but most of my organisation works with Windows. We frequently exchange links (via email / teams) to a network drive mapped to "D:\".

I am exploring an automation to convert MacOS filepaths to Windows filepaths using a small python script.

Expected Behaviour

Select Text -> Right-Click -> Services -> AutomationName -> Text gets replaced.

[EDIT: I can tell that the Automation is working because the text does get replaced. The issue is that it gets replaced with "Input", which is being passed onto Python as a string ("Input").

Issue

  • Cannot pass the "Selected Text" as a variable onto the python function.
  • The python function is working as expected in terminal.

Steps so far

enter image description here

Code:
# Convert MacOS Path to Windows Path

import sys

def MtW(link):
    wPath = link.replace("/Users/FF/Server","D:\\").replace("/","\\")
    print(wPath)

if __name__ == '__main__':
    globals()[sys.argv[1]](sys.argv[2])

Thank you for your support.
<p>I'm migrating to MacOS but most of my organisation works with Windows. We frequently exchange links (via email / teams) to a network drive mapped to "D:\".</p>
<p>I am exploring an automation to convert MacOS filepaths to Windows filepaths using a small python script.</p>
<p><strong>Expected Behaviour</strong></p>
<p>Select Text -> Right-Click -> Services -> <em>AutomationName</em> -> Text gets replaced.</p>
<p>[EDIT: I can tell that the Automation is working because the text does get replaced. The issue is that it gets replaced with "Input", which is being passed onto Python as a string ("Input").</p>
<p><strong>Issue</strong></p>
<ul>
<li>Cannot pass the "Selected Text" as a variable onto the python function.</li>
<li>The python function is working as expected in terminal.</li>
</ul>
<p><strong>Steps so far</strong></p>
<p><a href="https://i.sstatic.net/KPrdTpVG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KPrdTpVG.png" alt="enter image description here" /></a></p>
<pre><code># Convert MacOS Path to Windows Path

import sys

def MtW(link):
wPath = link.replace("/Users/FF/Server","D:\\").replace("/","\\")
print(wPath)

if __name__ == '__main__':
globals()[sys.argv[1]](sys.argv[2])

</code></pre>
<p>Thank you for your support.</p>
 

Latest posts

M
Replies
0
Views
1
Mohit Pant
M
Top