0

I am on Mac. I want to use terminal or something to extract the filepaths of the .MP4 files within a folder with multiple levels of subfolders. I have a main folder that has subfolders. Each subfolder has its own subfolders. Eventually in this line, there are .MP4 files. I want a text file with the filepath of each .MP4 file, preferably with commas or semicolons between. Can you help me?

I looked into a few options, but they were either for Windows or not that helpful. The dir command in Windows seemed relevant perhaps.

1 Answer 1

0

Ssmething like can help you (tested on RHEL):

printf "%s:" $(dirname $(find . -name "*.MP4") |sort -u)|sed 's/:$//'; echo

short explanations

find . -name "*.MP4"

search for filenames (with paths)

dirname $(find . -name "*.MP4") |sort -u

get directory name, sort and get unique dirctories

printf "%s:" $(dirname $(find . -name "*.MP4") |sort -u)

print the directory names and semicolon

sed 's/:$//'

remove last semicolon

echo 

on the end add new line

1
  • 1
    Thank you very much! Commented Mar 29 at 16:06

You must log in to answer this question.

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