Single/one line based solution, (to use/run in Terminal shell):
find "./" -not -type d -maxdepth 1 -iname "*.jpg" -print0 | while IFS= read -r -d $'\0' fileName ; do { echo "$fileName"; }; done; unset fileName;
for your/OP's case, change the "./"
into "/Users/nick/Desktop/"
To use in a script file:
#!/bin/bash
find "./" -not -type d -maxdepth 1 -iname "*.jpg" -print0 | while IFS= read -r -d $'\0' fileName ; do {
echo "$fileName";
# your other commands/codes, etc
};
done;
unset fileName;
or, use (recommended) below codes as script:
#!/bin/bash
while IFS= read -r -d $'\0' fileName ; do {
echo "$fileName";
# your other commands/codes, etc
};
done < <(find "./" -not -type d -maxdepth 1 -iname "*.jpg" -print0);
unset fileName;
Please checkout my other answer here for description of what code does what function.
As i have shown link to a description, i can avoid repeating same in here.