By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,175 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,175 IT Pros & Developers. It's quick & easy.

split question

P: 46
This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: 46
Never mind I found the answer to that. os.path.basename(filename)



This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 22 '06 #2

bartonc
Expert 5K+
P: 6,596
Thanks for keeping us up-to-date. This helps us a lot.
Nov 22 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.