title: Is there a way to change my file path automatically and apply a function in R?
body: <p>I'm looking to apply the 'multiple_sounds' function to a list of .WAV files from a folder using R. This is my current code:</p>
  <pre><code>##### 1 #####
  setwd(&quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;, resultfile = &quot;ndsi_results.csv&quot;, soundindex = &quot;ndsi&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;, resultfile = &quot;adi_results.csv&quot;, soundindex = &quot;acoustic_diversity&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;, resultfile = &quot;aei_results.csv&quot;, soundindex = &quot;acoustic_evenness&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;, resultfile = &quot;aci_results.csv&quot;, soundindex = &quot;acoustic_complexity&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_1&quot;, resultfile = &quot;H_results.csv&quot;, soundindex = &quot;bioacoustic_index&quot;, no_cores = &quot;-2&quot;)
  
  ##### 2 #####
  setwd(&quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;, resultfile = &quot;ndsi_results.csv&quot;, soundindex = &quot;ndsi&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;, resultfile = &quot;adi_results.csv&quot;, soundindex = &quot;acoustic_diversity&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;, resultfile = &quot;aei_results.csv&quot;, soundindex = &quot;acoustic_evenness&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;, resultfile = &quot;aci_results.csv&quot;, soundindex = &quot;acoustic_complexity&quot;, no_cores = &quot;-2&quot;)
  multiple_sounds(directory = &quot;E:/Audiomoth Files/Winter/Rural/Emma/_2&quot;, resultfile = &quot;H_results.csv&quot;, soundindex = &quot;bioacoustic_index&quot;, no_cores = &quot;-2&quot;)
  </code></pre>
  <p>This works, but at the moment I have to copy and paste this code each time for each folder(_1, _2, _3 etc.) of which there are 623, so doing this manually is very time consuming.</p>
  <p>Is there a way I can automate the file path to change the directory to go to _3, _4, _5 automatically and apply the function in a loop all the way to the 623rd folder?</p>
  <p>Thank you in advance</p>