Guest User

Copy Ardour session

a guest
Mar 5th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 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("Orchestre.ardour", ardourName)
  15.     os.rename("Orchestre.history", sys.argv[1] + ".history")
  16.     os.remove("Orchestre.ardour.bak")
  17.     os.remove("Orchestre.history.bak")
  18.    
  19.     os.rename("interchange/Orchestre" , "interchange/" + sys.argv[1])
  20.    
  21.    
  22.     #Modification of new .ardour file to incorporate the name of the session
  23.     # We assume that   <Session version="3001" name="theName" sample-rate="44100" id-counter="27095" event-counter="0">
  24.     # is the second line of the file
  25.     f = open(ardourName, "r")
  26.     modifiedFile = open(ardourName + "2", "w")
  27.     nLine = 0
  28.     for line in f :
  29.         if nLine == 1 :
  30.             modifiedFile.write("<Session version=\"3001\" name=\"" + sys.argv[1] + "\" sample-rate=\"44100\" id-counter=\"27095\" event-counter=\"0\">\n")
  31.         else:
  32.             modifiedFile.write(line)
  33.         nLine += 1
  34.     f.close()
  35.     modifiedFile.close()
  36.     os.rename(ardourName + "2", ardourName)
Advertisement
Add Comment
Please, Sign In to add comment