I tried to code a bash script that loops through a given directory and all its subdirectories and extracts metadata attributes with the mdls
command into separate text files. Since I have a lot of filenames containing spaces and other special characters, my code base is derived from the answer "Looping through files with spaces in the names?".
But after each file the script waits
for pressing Enter/Return manually.
How can I make it automatically loop through files and folders?
#!/bin/bash
# write metadata of files in separate file
find . -type f -name '*.*' -exec sh -c '
for file do
echo "$file"
mdls "$file" > "$file"_metadata.txt
read line </dev/tty
done
' sh {} +