Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python script for changing windows path to unix path

I want a script where I can paste a windows path as argument, and then the script converts the path to unix path and open the path using nautilus.

I want to be able to use the script as follows:

mypythonscript.py \\thewindowspath\subpath\

The script currently looks like this:

import sys, os

path = "nautilus smb:"+sys.argv[1]

path = path.replace("\\","/")

os.system(path)

I almost works :) The problem is that I have to add ' around the argument... like this:

mypythonscript.py '\\thewindowspath\subpath\'

Anyone who knows how I can write a script that allows that argument is without ' , ... i.e. like this:

mypythonscript.py \\thewindowspath\subpath\

EDIT: I think I have to add that the problem is that without ' the \ in the argument is treated as escape character. The solution does not necessarily have to be a python script but I want (in Linux) to be able to just paste a windows path as argument to a script.

like image 775
user1489737 Avatar asked Nov 13 '22 03:11

user1489737


1 Answers

Unless you're using a really early version of Windows: "/blah/whatever/" just works for your OP.

like image 185
Jon Clements Avatar answered Dec 08 '22 00:12

Jon Clements