osx: how to write the full path of all directory contents of a folder containing >50k files&folders to a txt

StackOverflow https://stackoverflow.com/questions/9154830

Question

I'm trying to find is a (1.) low risk (no messing with the files), (2.) dependable, (3.) uncomplicated, and (4.) reasonably effective way to write the posix path of every single file and folder in a directory with 50k plus files and folder to a txt. The txt should contain nothing but the paths, one line per path. The order of the files is not particularly important as long as they are all there.

In applescript, you can get the paths of all files and folder in a directory this way:

tell application "Finder"
    set file_list to entire contents of (choose folder with prompt "Please select directory.")
end tell

But this crashes finder when used on the folder in question. There must be some other solution? Or perhaps a way to make the applescript work?

Was it helpful?

Solution

Does this produce the expected output?

find /dir -print > output.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top