Created
July 3, 2023 12:30
-
-
Save tonyedwardspz/5d9e1734af330b8f4ad50e64a678e7a8 to your computer and use it in GitHub Desktop.
Revisions
-
tonyedwardspz created this gist
Jul 3, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/bin/bash # Loop through all directories in the current directory for directory in */; do # Check if it's a directory if [[ -d "$directory" ]]; then # Remove trailing slash dir_name="${directory%/}" # Construct file names m4b_file="${dir_name}.m4b" pdf_file="${dir_name}.pdf" # Check if the corresponding .m4b and .pdf files exist in the directory if [[ -f "${directory}/${m4b_file}" ]] && [[ -f "${directory}/${pdf_file}" ]]; then # If they do, move the .m4b and .pdf files to the current directory mv "${directory}/${m4b_file}" ./ mv "${directory}/${pdf_file}" ./ # Remove the directory rmdir "${directory}" echo "Moved ${m4b_file} and ${pdf_file} out of ${directory}" fi fi done