I'm trying to use a shell script to:

  • return all .mov files in a given directory
  • without path, file names only
  • filtering out dot-underscore files from results
  • separate each result by \n but haven't even gotten to that part

I don't know why there are dot underscore files, but it's a shared server so I didn't want to delete them just in case. There are also spaces in the Path, so separating results by spaces gives interesting results.

So far I've figured out how to do these things but not in tandem. This command will return all results, no dot underscore files, but it returns only the full path, can't get it to return basename:

results="$(find /Path/ -iname "*.mov" -type f | grep -vF '/._')"

And then this command will return only basenames, but includes dot-underscore files

results="$(find /Path/ -iname "*.mov" -execdir echo {} ';' | grep -vF '/._')"

As you can see in the second attempt I tried to link the two together... but somehow -execdir is making the command ignore the grep command at the end. I'm sure I'm just piping something wrong, but please let me know.

  • Please show a couple of typical paths, with and without the "dot underscore" Mar 23, 2022 at 18:34
  • Hey @glennjackman luckily the dot underscore issue is only files, not in the path names. So the path names are pretty normal. Have some spaces, but nothing an escape keep can't solve. The dot underscore issue is only in the results. All my results are doubled, it returns "File1.mov" and "._File1.mov", "File2.mov" and "._File2.mov" Mar 23, 2022 at 18:45
  • 1
    What do you intend to do with result afterwards, why do you need newlines in there?
    – nohillside
    Mar 23, 2022 at 18:51
  • @nohillside I intend to print it all to a Text file. Then us VSCode to compare it to another text file that shows me all files currently imported into Adobe Premiere. We've been having issues knowing if everything has been imported. There might be 1000 files on the server and somehow only 985 made it into the program. Trying to find a way to compare the list by text instead of manually hunting through folders. Mar 23, 2022 at 19:32

1 Answer 1


You can use find to skip unwanted files, no need to grepafterwards:

find PATH \( -name '._*' -prune \) -o -type f -iname '*.mov' -execdir echo {} \;

To create a text file with the result, add > path/to/text-file at the end.

PS: The reason your second command doesn't work is in the pattern used for grep. You strip out the path name in the find, so grep -v '^\._' should be used instead.

  • Also, . is a single-character wildcard in regular expressions, so grep -v '^._' will remove all names with "_" as the second character, no matter what the first character is. find's -name primary uses glob syntax instead of regex, so this isn't a problem there. Mar 23, 2022 at 19:30
  • @GordonDavisson Ah, right, fixed.
    – nohillside
    Mar 23, 2022 at 19:31
  • @nohillside that command worked perfectly, you're blowin my damn mind. Thanks so much, I need to go research -prune Mar 23, 2022 at 19:34
  • @Car_SharkHybrid You're welcome. man find is your friend here. Also, apple.stackexchange.com/help/someone-answers might be of interest.
    – nohillside
    Mar 23, 2022 at 19:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .