Skip to main content
Remove the uniq
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdiroutput_file=$output_dir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress "${files[@]##*/} "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress "${files[@]##*/} "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subshell

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$output_dir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress "${files[@]##*/} "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.
Change *.mp3 to "${files[@]##*/}"
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress  *.mp3"${files[@]##*/} "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress  *.mp3 "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress "${files[@]##*/} "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.
edited body
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12

This does the cd in a subhsellsubshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress  *.mp3 "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subhsell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress  *.mp3 "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.

This does the cd in a subshell and is using GNU uniq because of the -z

#!/usr/bin/env bash

shopt -s nullglob

input_dir=$1
output_dir=$2

mkdir -p "$output_dir"

while IFS= read -rd '' dir; do
  files=("$dir"/*.mp3)
  if (( ${#files[*]} )); then
    ( 
     cd "$dir" || exit
     output_file=$out_putdir/${PWD##*/}
     echo " Output: $output_file"
     echo sox --show-progress  *.mp3 "$output_file"
    )
  fi 
done < <(find "$input_dir" -type d -print0 | uniq -z)
  • Remove the echo before the sox If you think the output is correct.
  • I have never used sox before just so you know.
edited body
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12
Loading
Source Link
Jetchisel
  • 1.6k
  • 9
  • 12
Loading