Sample Header Ad - 728x90

Find - xargs, for every line open a new shell and execute a command and wait for user to exit that shell

0 votes
1 answer
118 views
### Following works - **Task**: List all folders that contain file of iname *AlbumArt* that also contain iname *cover*.jpg, and for each of those folder list all jpg files with size
{.bash .numberLines}
  find . -type f -iname '*AlbumArt*' -print0 | sort -z \
    | xargs -0 -I "{}" bash -c '
    find "$(dirname "${1}")" -maxdepth 1 -iname "*cover*.jpg" -print0' _ "{}" \; \
    | uniq -z | xargs -0 -I "{}" bash -c '
    ls -la "$(dirname "${1}")"/*.jpg;' _ "{}" \;

## What I actually want to do?

I want to list all folder that contain iname *cover*.jpg and iname*AlbumArt* and list the size of each image file in that folder and also open nautilus so that I can manually inspect those images in that folder (as I want to delete some extra files), this I want to do one folder at a time. So for each output of xargs I want to do ls -la and open nautilus and wait for nautilus to close so I added nautilus "${1}";  read -r -p "Press any key to continue" Continue; to above:
{.bash .numberLines} find . -type f -iname '*AlbumArt*' -print0 | sort -z \ | xargs -0 -I "{}" bash -c ' find "$(dirname "${1}")" -maxdepth 1 -iname "*cover*.jpg" -print0' _ "{}" \; \ | uniq -z | xargs -0 -I "{}" bash -c ' ls -la "$(dirname "${1}")"/*.jpg; nautilus "${1}"; read -r -p "Press any key to continue" Continue;' _ "{}" \; ``` This works but it won't stop for user input as per read -r -p "Press any key to continue" Continue; i.e. several windows of nautilus opens! But I want to open only one nautilus at a time so I want xargs to wait after each execution of the line. What should I do to make xargs wait for user input after each line of execution?
Asked by Porcupine (2156 rep)
Mar 31, 2024, 02:37 PM
Last activity: Apr 1, 2024, 06:51 AM