documents

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

wav2flac.nu (623B)


      1 def main [
      2     path: path    # 変換対象のディレクトリパス
      3 ] {
      4     if not ($path | path exists) {
      5         print $"Error: Path '($path)' does not exist."
      6         return
      7     }
      8 
      9     let targets = (ls ([$path, "*.wav"] | path join))
     10 
     11     if ($targets | is-empty) {
     12         print "No .wav files found."
     13         return
     14     }
     15 
     16     $targets | par-each { |it|
     17         let output = ($it.name | str replace --regex '(?i)\.wav$' '.flac')
     18         print $"Converting: ($it.name) -> ($output)"
     19         
     20         ffmpeg -i $it.name -compression_level 8 -loglevel error $output
     21     }
     22 
     23     print "Done."
     24 }