Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####
- ## CD to Junction for Total Commander
- ## License: MIT or CC-BY
- ## Author: Maciej "Nux" Jaros
- ####
- import subprocess,sys,os
- # settings
- tcExePath = r'c:\Progs\Totalcmd\TOTALCMD64.EXE'
- junctionExePath = r'c:\Progs\Varia\Junction\junction.exe' # TCPROGS - system env. variable
- # check and set args
- dirPath = r'c:\Users\All Users' # test
- if len(sys.argv)>=2:
- dirPath = sys.argv[1].rstrip() # Need to add quotes and space in TC e.g.: "C:\Blah\ "
- ##
- # Get original path of the junction
- #
- def getOriginalPath(junctionPath):
- cmd = subprocess.Popen(junctionExePath + ' \"' + junctionPath + '\"', shell=True, stdout=subprocess.PIPE)
- for line in cmd.stdout:
- if line.find('Substitute Name:') >= 0:
- start = line.find(':')
- return line[start+1:].strip(" \t\n\\?")+"\\"
- break
- return ""
- ##
- # Change Total Commander current directory
- #
- def cdTC(newPath):
- subprocess.Popen(tcExePath + ' /O /S /L=\"' + newPath + '\"')
- #
- # Get and CD
- #
- realPath = getOriginalPath(dirPath)
- if len(realPath) >= 1:
- cdTC(realPath)
- else:
- cdTC(dirPath)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement