|
From: Fmiser <fm...@gm...> - 2010-06-28 02:42:49
|
> Fernando Ossandon wrote: > I'm just starting to use sox. > I have been using the following to resample some 24bit 96kHz > files to 16bit 44kHz: > sox -S OriginalFile.flac -r 44100 -b 16 NewFile.flac > > Is there any way to apply that command to a batch script and > be able to resample all files in a given folder and put the > new ones in another folder? > Can anyone give me an script example? (or any other advice to > batch process the command) You don't mention your operating system. With a bash shell (the most common Linux terminal) Do do it as a one-liner entered at the promtp: for i in ./*.flac;\ do sox -S $i -r 44100 -b 16 "converted/$i";\ done In this case, the shell expands "./*.flac" to be a list of every flac file in the current directory. So make sure your current directory is where the files are that need converting. Bash then steps through each of the .flac files in the list, converts them one at a time, and puts the converted one in the directory "converted" in the current directory. The "\" at the end of the line tells bash to ignore the very next character. In this case it's the new-line, which makes it a one-liner command even though it's four lines long... To do the same sort of thing as a script _file_ -----------------------< cut here >-------------------------- !#/bin/bash # A simple script to convert a batch of flac files. The source # files are given as a command option. It can include # wildcards. The destination is reletive to the current # directory of where you were when the script was run. # # Example: convertflac.sh /home/Foo/audio/*.flac # Set the directory you want for the converted files OutDir=converted # Get the list of files from the command line, # # Convert the file with SoX, strip any directory data from the # front of the input file and use that as the output filename # putting it in OutDir for input in "$@" do sox -S $input -r 44100 -b 16 "$OutDir/$(basename $input)" done # The script will end when the list of input files is # exhausted. -----------------------< cut here >-------------------------- If you are using MS Win, a batch file is similar, but the details of input list and output filename are different. I can't help much there... -- Philip, heavy bash user. |