On Sun, Jan 16, 2022 at 02:48:00PM -0600, David Wright wrote: > You obviously meant something else by "Every extracted file must be in > the same directory" from the literal meaning that I employed.
Yes, the wording is quite ambiguous. > "My problem is extracting 7z files … into their own directories." > > I can't parse this either. The original request has at least three possible interpretations. Let's assume that they've got a directory structure like this: TOPLEVEL/dir1 /dir2 /sub1 /sub2 /dir3 So, there are 5 directories (not counting TOPLEVEL): 3 at depth 1 below TOPLEVEL, and 2 at depth 2 below TOPLEVEL. Let's assume there are *.7z files in all 5 of these directories. The first interpretation is "I want all of the extracted files in TOPLEVEL". That's how I read it at first. That's the interpretation which leads to all of the output files being in the same directory, after all. The second interpretation is "I want the extracted files from TOPLEVEL/dir1/foo.7z to be in TOPLEVEL/dir1, and the extracted files from TOPLEVEL/dir2/sub1/bar.7z to be in TOPLEVEL/dir2/sub1, and so on." Given the second quoted statement above, I believe they want the second interpretation. A lot of responders in this thread seemed to assume that from the outset, hence the suggestions involving -execdir, which only makes sense under the second interpretation. For the record, given the second interpretation, I agree that find -execdir is a perfect fit. Now, there's at least a third possible interpretation. It's possible that given the source file TOPLEVEL/dir2/sub2/baz.7z, they would like to create the depth 3 directory TOPLEVEL/dir2/sub2/baz and then extract baz.7z into that new directory. There could be other valid interpretations as well. The only way we'll ever know for sure what the OP wants is if the OP gives an actual example, with pathnames. Ideally the real pathnames, but we all know that won't happen....