Closed Sidharth-Singh10 closed 5 months ago
hi @Sidharth-Singh10, please avoid putting full code explanation in PR description! PR description is a general overview of what your changes will do/fix, and high level description of how you fixed it, any system metadata etc.
@Sidharth-Singh10 There is a bug in your implementation, can you check it once?
fixes #91
@rootCircle I tried to solve the bug to best of my knowledge. I failed to do so. I am closing this PR as I cannot move further.
This script is designed to convert all .mp4 files in the current directory and its subdirectories into .mp3 files and store them in the Music directory. Here's a breakdown of the implementation:
output_dir="$(pwd)/Music"
: Defines the output directory as Music within the current directory.fd . -e 'mp4'
: This command finds all files (fd) in the current directory (.) and its subdirectories that have the .mp4 extension.while read -r file; do ... done
: Loops through each found .mp4 file.filename_no_ext="${file%.*}"
: Extracts the filename without the extension. For example, clips/Sequence04.filename_with_ext="${file}"
: Stores the filename with the extension. For example, clips/Sequence04.mp4.output_file="${output_dir}/${filename_no_ext}"
: Defines the output file path, including the output directory and filename without extension. For example, Pictures/Music/clips/Sequence04.dir_name=$(dirname "$filename_with_ext")
: Extracts the directory name. For example, clips.mkdir -p "$output_dir/$dir_name"
: Creates the corresponding directory in the Music directory. For example, Pictures/Music/clips.input="$(pwd)/$filename_with_ext"
: Defines the input file path. For example, /home/baka/Pictures/clips/Sequence04.mp4.output="${output_file}.mp3"
: Defines the output file path with the .mp3 extension. For example, /home/baka/Pictures/Music/clips/Sequence04.mp3.ffmpeg -i "$input" "$output"
: Uses ffmpeg to convert the .mp4 file to .mp3 and save it in the specified output directory.Overall, the script finds all .mp4 files, creates the corresponding directories in the Music directory, and then converts each .mp4 file to .mp3, storing them in the Music directory.