0

I have to convert a large number of audio files from .wav format to .flac format in order to save storage space on our server. The code for doing this on a single file looks like this:

wav2flac("TestFile.wav", reverse = FALSE, overwrite = FALSE,
         exename = "flac.exe", path2exe = "C:/Program Files/FLAC/flac-1.3.2- 
         win/win64")

How do I loop the command to perform on an entire directory of these .wav files?

zx8754
  • 52,746
  • 12
  • 114
  • 209

1 Answers1

1

If the files are all in the same folder and in that folder there are only the files you need, then you can use list.files to find out all their paths then sapply to loop over them

files = list.files('C:/Yourfolderhere', full.names = T)
sapply(files, wav2flac, reverse = FALSE, overwrite = FALSE, exename = "flac.exe", path2exe = "C:/Program Files/FLAC/flac-1.3.2- win/win64")
Luis
  • 629
  • 4
  • 9