0

I know this is a common error but I'm really stuck and could use some help.

I need to create an Excel sheet of any files in a subdirectory named Parent, that exists in the root folder Tabletop. This is what I have:

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f > Parent_Files_TT.csv 

It searches for folders named Parent and then copies the full file path to Excel. This has worked on other smaller folders I have, but Tabletop has hundreds of thousands of files in it and I get the error:

/usr/bin/find: Argument list too long

I have tried to modify this to use xargs when finding the file:

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f -print0 | xargs > Parent_Files_TT.csv 

And have also tried "*":

find $(find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop -type d -iname parent | xargs) -type f -name "*" > Parent_Files_TT.csv 

But I'm getting the same error. If someone can help me modify this I'd be really grateful.

3
  • Don't you need to pair xargs -0 with find ... -print0? Commented Feb 13, 2018 at 19:47
  • I was really confident that this would work actually, by adding -type f -print0 | xargs -0, but unfortunately I still get the same error. Commented Feb 13, 2018 at 19:58
  • I think the find $(...) part is the problem here. You're interpolating a massive thing. Try restructuring this to pipe the result of the first find into the second somehow. Commented Feb 13, 2018 at 20:05

2 Answers 2

2

This part

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \ -type d -iname parent 

returns too many results, and your outer command becomes too long. You can avoid that by nesting your finds differently:

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \ -type d -iname parent \ -exec find {} -type f \; > Parent_Files_TT.csv 
Sign up to request clarification or add additional context in comments.

Comments

1

Rather than putting a find in your find, just do it in one pass:

find /Volumes/COMMON-LIC-PHOTO/STUDIO-COMPLETE/ARCHIVE/Tabletop \ -ipath '*/parent/*' -type f 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.