how to burn/write files in a cd-r/rw using bash scripting
hello there again...i have created a script that will open a hdd then close...i want to add a script that would burn my, let's say, mp3 files from the /home/username directory to the media(cd-r/cd-rw)...sad ly, i don't know how to manipulate these mp3 files, transfer them to the burner, then burn the files...
here's my script as for now: #!/bin/bash clear eject /dev/hdd sleep 5 eject -t /dev/hdd if [ "$?" -eq "0" ]; then nautilus /media/cdrecorder1 sleep 5 eject /dev/hdd sleep 5 eject -t /dev/hdd else exit 1 fi when nautilus closes, it will pause for 5 secs then eject the medium... help pls :D |
The 'eject -T' command I told you about earlier will act as a toggle. Not sure what all the sleeping is about. You could have an interactive prompt, like 'press enter when ready' instead. And, if the script is to burn CDs, you have everything around that, but no *that*. :) Read the man page for cdrecord - it's pretty simple (if your task is simple) but I try to avoid optical media as much as possible. You might check out bashburn rather than reinvent the wheel, unless this is just a learning exercise.
|
ohh..uhmmm...sleeping is the time given for the user to place his media on the drive...let's say, for 5 seconds..hehe...im currently viewing the man page for cdrecorder...lol...and again, too complicated for a noob like me, but im trying...this script is a learning exercise at the same time, for lazy person like me...a ready made script for burning audio and data files will be very useful :D
|
right - maybe something like 'read -t30 -n1 -ep "Hit any key when ready..."' - five seconds doesn't seem like much time - this way the script will let you go as fast or slow as you want up to a point, but still not hang the script forever. OTOH, I'm fond of completely non-interactive scripts, so I can see the pros of avoiding a prompt, too. The bashburn script is findable at either freshmeat or sourceforge (or both). Search this site for threads on cdrecord - there are several examples - basically 'cdrecord OPTIONS DEVICE FILE', IIRC.
|
Here is a modified version of your script. Feel free to change/delete/add whatever you want.
Its a good way to do what you wanted, and a good thing to play around with. I've tested everything but the actual cd-burning command. It may look like a lot, but read through the comments and it may seem very simple. To test it I commented out the sleep, eject, and just echoed the cdrecord commands Code:
#!/bin/bash |
Quote:
|
:) Go ahead and read through the comments. And feel free to ask about any command you don't understand.
|
How about this: BashBurn
|
All times are GMT -5. The time now is 06:17 PM. |