Batch Scripts with other programs
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Batch Scripts with other programs
I'm making this thread as a location for anyone wanting to submit any batch scripts for audio processing with other audio applications.
Examples might be batch converting files to WAV using Lame with a cmd or Powershell script (Windows), or batch converting using a Python script with pacpl (Pear Audio Converter - Linux).
Please state the program and scripting language used in the script, plus a description of what the script does.
Add other details as appropriate.
Examples might be batch converting files to WAV using Lame with a cmd or Powershell script (Windows), or batch converting using a Python script with pacpl (Pear Audio Converter - Linux).
Please state the program and scripting language used in the script, plus a description of what the script does.
Add other details as appropriate.
Add 10% silence to start of files
Applications: SoX, Soxi, bc
Platform: Linux
Scripting language: Bash
Here's a batch processing script that will add a period of silence to the beginning of each WAV file in a folder and place the output files in an output folder.
It could be easily adapted to add a fixed number of second of silence to the beginning or end of each file.
For different file formats, provided they are supported by SoX, simply change the file extension at the start of the loop.
Platform: Linux
Scripting language: Bash
Here's a batch processing script that will add a period of silence to the beginning of each WAV file in a folder and place the output files in an output folder.
It could be easily adapted to add a fixed number of second of silence to the beginning or end of each file.
For different file formats, provided they are supported by SoX, simply change the file extension at the start of the loop.
Code: Select all
#!/bin/bash
## script to add 10% silence to beginning of each WAV track in current folder
if [ -d "output" ]
then echo "Folder already exists"
else mkdir "output"
fi
# start loop
for filename in *.wav
do
# get file properties
slength=$(soxi -D $filename)
schan=$(soxi -c $filename)
srate=$(soxi -r $filename)
# Bash only does integer arithematic, so us bc to calculate 10% length
slength=$(echo "$slength*0.1" | bc)
# make silence
sox -n -c $schan -r $srate "output/temp.wav" trim 0 $slength
# concatenate silence and file
sox "output/temp.wav" $filename "output/$filename"
done
# clean up temp files
rm "output/temp.wav"
# end
Learn more about Nyquist programming at audionyq.com
-
- Posts: 1
- Joined: Mon May 30, 2011 8:45 am
- Operating System: Please select
bash script to convert audacity labels to cue sheet
[NB: this post is going to be most useful to Linux users and people who know how to convert/use a bash script]
While I am aware that there is already a great way of convert Audacity labels to cue sheets (label2cue - http://forum.audacityteam.org/viewtopic.php?f=21&t=551), I wanted something that would provide a little more information on the finished cue sheet, particularly artist and track titles. I mainly burn DJ mixes to CD, and need all the information easily available to CD-Text.
So, I wrote this bash script > <, which will scan a folder for wav files with a labels.txt file, and convert the labels.txt file to a cue sheet. It gives interactive control over the album title and album artist, and will automatically save the cue sheet's 'FILE' parameter as the name of the wav file, with 'WAVE' as the type. I use the same calculations as the label2cue Java program (thanks to 'AndrewTheArt' for authoring that), so the index times on the resulting cue sheets should be identical.
To get the bash script to run, you will need the following programs on Linux: zenity, tr, cut, bc, sed - all except zenity are likely to be part of a standard installation. However, you will also this 'bc' file > <, uploaded to your home directory. If you upload it to another directory, you will need to change all instance of "bc ~/bc" in the bash script, replacing the tilde (~) with the full path to your home directory. Someone who knows bc better than I do might be able to make this work without the additional bc file...
If anyone can improve on or alter this script, please do so and post it up here for the benefit of others and myself. I am no bash expert, and, while I have found this works fine for me and does not do anything unpleasant, I am sure there will be the odd mistake in there. Anyway, I hope someone finds it useful.
I wrote a blog post about burning gapless mix CDs, which someone also might find useful: http://www.djkaboodle.co.uk/blog/2011/m ... xes-cd-how. Again, any corrections or improvements are appreciated.
Regards,
DJ Kaboodle.
While I am aware that there is already a great way of convert Audacity labels to cue sheets (label2cue - http://forum.audacityteam.org/viewtopic.php?f=21&t=551), I wanted something that would provide a little more information on the finished cue sheet, particularly artist and track titles. I mainly burn DJ mixes to CD, and need all the information easily available to CD-Text.
So, I wrote this bash script > <, which will scan a folder for wav files with a labels.txt file, and convert the labels.txt file to a cue sheet. It gives interactive control over the album title and album artist, and will automatically save the cue sheet's 'FILE' parameter as the name of the wav file, with 'WAVE' as the type. I use the same calculations as the label2cue Java program (thanks to 'AndrewTheArt' for authoring that), so the index times on the resulting cue sheets should be identical.
To get the bash script to run, you will need the following programs on Linux: zenity, tr, cut, bc, sed - all except zenity are likely to be part of a standard installation. However, you will also this 'bc' file > <, uploaded to your home directory. If you upload it to another directory, you will need to change all instance of "bc ~/bc" in the bash script, replacing the tilde (~) with the full path to your home directory. Someone who knows bc better than I do might be able to make this work without the additional bc file...
If anyone can improve on or alter this script, please do so and post it up here for the benefit of others and myself. I am no bash expert, and, while I have found this works fine for me and does not do anything unpleasant, I am sure there will be the odd mistake in there. Anyway, I hope someone finds it useful.
I wrote a blog post about burning gapless mix CDs, which someone also might find useful: http://www.djkaboodle.co.uk/blog/2011/m ... xes-cd-how. Again, any corrections or improvements are appreciated.
Regards,
DJ Kaboodle.
Re: Batch Scripts with other programs
Thank you for SoX script steve! I searched through half of web to find it here! Lol
Re: Batch Scripts with other programs
You're welcome. 

Learn more about Nyquist programming at audionyq.com
Recursive processing with a bash script
Applications: SoX
Platform: Linux
Scripting language: Bash
I originally wrote this for someone that wanted to change the sample rate of their entire music collection from 192 kHz to 48 kHz FLAC format (http://forum.audacityteam.org/viewtopic ... 48&t=72838) but it could be easily adapted for other batch processing jobs where recursion through a folder hierarchy is required.
As with other scripts provided here, this comes with no guarantee of any sort and is entirely at the users risk.
Note also that this script must run in Bash and not in Dash.
Giving in a .sh extension, making it executable and then double clicking on the script file should work but if not run it from the command line with
In its current form, the script should be run from within the top level of the folders containing the flac files.
The "output" path (near the top of the file) will need to be changed to suit the computer that it is being used on.
Platform: Linux
Scripting language: Bash
I originally wrote this for someone that wanted to change the sample rate of their entire music collection from 192 kHz to 48 kHz FLAC format (http://forum.audacityteam.org/viewtopic ... 48&t=72838) but it could be easily adapted for other batch processing jobs where recursion through a folder hierarchy is required.
As with other scripts provided here, this comes with no guarantee of any sort and is entirely at the users risk.
Note also that this script must run in Bash and not in Dash.
Giving in a .sh extension, making it executable and then double clicking on the script file should work but if not run it from the command line with
Code: Select all
bash filename
The "output" path (near the top of the file) will need to be changed to suit the computer that it is being used on.
- Attachments
-
- sox-recursive-batch-converter.txt
- (668 Bytes) Downloaded 620 times
Learn more about Nyquist programming at audionyq.com
Re: Batch Scripts with other programs
Thanks to djkaboodle for the labelcue script!
It took me a while to find it here... It works perfectly with K3b.
I made a small change for myself: I set $artist = $performer, because I made a cuesheet for a live performance of a band.
Regadrs,
Ko
It took me a while to find it here... It works perfectly with K3b.
I made a small change for myself: I set $artist = $performer, because I made a cuesheet for a live performance of a band.
Regadrs,
Ko