Advertisement
Guest User

Copy Ardour session

a guest
Mar 5th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. import sys
  4. import shutil
  5. import os
  6.  
  7. if len(sys.argv) != 2 :
  8.     print ("Please give a name for the new project")
  9. else :
  10.     #Copy the Orchestre folder which has to be in the same folder as the script
  11.     shutil.copytree("Orchestre", sys.argv[1], symlinks=True)
  12.     os.chdir(sys.argv[1])
  13.     ardourName = sys.argv[1] + ".ardour"
  14.     os.rename("Orchestra.ardour", ardourName)
  15.     os.rename("Orchestra.history", sys.argv[1] + ".history")
  16.     os.remove("Orchestra.ardour.bak");
  17.     os.remove("Orchestra.history.bak")
  18.    
  19.     #Modification of new .ardour file to incorporate the name of the session
  20.     # We assume that   <Session version="3001" name="Orchestra" sample-rate="44100" id-counter="27095" event-counter="0">
  21.     # is the second line of the file
  22.     f = open(ardourName, "r")
  23.     modifiedFile = open(ardourName + "2", "w")
  24.     nLine = 0
  25.     for line in f :
  26.         if nLine == 1 :
  27.             modifiedFile.write("<Session version=\"3001\" name=\"" + sys.argv[1] + "\" sample-rate=\"44100\" id-counter=\"27095\" event-counter=\"0\">\n")
  28.         else:
  29.             modifiedFile.write(line)
  30.         nLine += 1
  31.     f.close()
  32.     modifiedFile.close()
  33.     os.rename(ardourName + "2", ardourName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement