NeroCmd.exe and Python – Automating the Burning Process
Nero* includes a nice little executable that lets you control CD/DVD burning via the command line. It is called “NeroCmd.exe” and should be located somewhere in your “C:\Program Files\ahead\Nero\”.
Just call it from the command line with no arguments and it will dump a few pages of documentation** at you to get you started. i.e.
>"C:\Program Files\ahead\Nero\NeroCmd.exe"
As an example of how to put all of its many parameters together, I used it to burn an ISO file to a DVD like so:
C:\Program Files\ahead\Nero>"C:\Program Files\ahead\Nero\NeroCmd.exe" --write --drivename D --real --dvd --image "C:\BACKUPTEMP\NON_COPYRIGHTED_FILE.ISO"
--speed 6 --underrun_prot --no_user_interaction
If you’re curious what you could use something like this for, I wrote a little Python script that will read all of the files in a folder, pull out an ISO file, and burn it to a disk. It runs once a night. After the run it tells me the name of the file it burned and pleads with me to insert a blank disk for its next run.
"""
Autoburn.py
Greg Pinero
January 2006
--
A little script to automate the burning of my ISO files to DVD.
"""
import sys
import os
import shutil
#-----------------------------------------------------------------------------
#USER SETTINGS:
StoredISOsPath=r'C:\DVDBACKUPTEMP'
BurnedISOsPath=r'C:\DVDBACKUPTEMP\haveonDVD'
NeroCMDPath=r'C:\Program Files\ahead\Nero\NeroCmd.exe'
#-----------------------------------------------------------------------------
for filename in os.listdir(StoredISOsPath):
if filename.split(os.path.extsep)[-1].upper()=='ISO':
fullisopath=os.path.join(StoredISOsPath,filename)
launchstring=r'""%s" --write --drivename D --real --dvd --image ""%s"' % (NeroCMDPath,fullisopath)
launchstring+=' --speed 4 --underrun_prot --no_user_interaction' #psuedo line break for code
resultcode=os.system(launchstring)
print resultcode
if resultcode==0:#sucess,move iso
shutil.move(fullisopath,os.path.join(BurnedISOsPath,filename))
print "I sucessfully burned %s to the disk in the tray, please label it accordingly"
print "Please insert a blank DVD into the drive."
else:
print "I hit an error, most likely there was no disk in"
pause=raw_input("Press enter to exit")
sys.exit(resultcode)
print 'no files found'
pause=raw_input("Press enter to exit")
sys.exit(0) #no files found
*You could try CreateCD if you want a free alternative to Nero that offers command line control.
**I read that more documentation is available from Nero, but I didn’t need it.
Update: If you get an error from Nero command from my script try changing this line:
launchstring=r'""%s" --write --drivename D --real --DVD --image ""%s"' % (NeroCMDPath,fullisopath)
to:
launchstring=r'""%s" --write --drivename D --real --DVD --image "%s"' % (NeroCMDPath,fullisopath)
os.system is a delicate lady indeed!
[...] Answer My Searches » Blog Archive » NeroCmd.exe and Python – Automating the Burning Process Nero* includes a nice little executable that lets you control CD/DVD burning via the command line. It is called “NeroCmd.exe” and should be located somewhere in your “C:Program FilesaheadNero”. [...]
One way I found to make nero commands more compatible is by making a temporary batch file with the command and then using os.system to call it instead of using os.system directly. I also made a list of nero errorcodes based on their manual for anyone interested…
please send the source code for cd burning using python or c++ versions as immediately as possible
Sachin, I’m not sure what source code you would want. The only code you need is in the post.
Does this script imply that it can only burn the first ISO? What if you have two ISO files in the folder that it reads from? Unless you have some multiple DVD burners or a burner that can rotate DVD’s, it will error out, correct?
webjoe, each time you run the script it will burn one ISO file. Just schedule it to run say every night and it will work its way through your ISO files. After burning it moves the file to separate directory so it won’t reburn anything.
It does of course depend on you to keep putting in blank DVD’s. I don’t know a good way around that.
Hope that answers your question.
How to extract iso image file and brun it on the CD-R