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.
Considering this file structure:
After installing
findutilswith this command:then running this command in the terminal:
should fill
~/file.txtwith this content:Some insights:
The
-fprintfoption ofgfind(orfind) prints the result in the specified format (here'%p',) to the specified file (here~/file.txt).In the
'%p',format:%puses the path and name of the found items, starting from the beginning of the searched path (here/Users/You/main_dir, implying that%pwill start from the root/),') to deal with possible spaces and/or commas in the file paths,,(comma, space) are appended.