0

Ive been looking for how I can output a list of files of specific folder and the all nested items which is like below. I have no enough disk already so I can not install macports to have tree command. Please advice me.

I would like to have the output like below.

For Example when to make a list of Documents folder:

  • /useraccount/documents/test1/test1.odt 20140326 19:00:00
  • /useraccount/documents/test1/test2.odt 20140326 19:01:00
  • /useraccount/documents/test1/test11/test.odt 20140326 19:05:00
  • /useraccount/documents/test2/test1.odt 20140326 19:02:00
  • /useraccount/documents/test2/test2.odt 20140326 19:01:30
  • /useraccount/documents/test1.odt 20140325 19:01:30

Background:

Why I don't move the files to external drive is that the date has changed by someone at home. A weeks ago, I believe I could see proper date and time and also, I have been used this But I can not find any files has proper date and time. All files has changed. This is not my mistake. I need to keep the date and time before moving.

asked Mar 26, 2014 at 9:52
2
  • What I don't understand is what you really need. You want the files back with their original date/time? Or you want to know which files have changed? If you want to move files over to another disk and keep the current timestamp, use rsync. That will keep date and time. You can make a copy, then check if it's OK, then remove the original files. Commented Mar 26, 2014 at 16:18
  • I just want to have the list of file name, folder name and time stamp under specific folder with sub folders. Anyway, The time stamp has back now without changing anything. Commented Mar 27, 2014 at 4:27

2 Answers 2

3

You can use the find command scan the directory, and have it execute stat to print information about each item it finds:

find /useraccount/documents -exec stat -f "%N %Sm" {} +

but the date is in a different format than you want (e.g. "Mar 26 19:00:00 2014" instead of "20140326 19:00:00"). You could also use %m instead of %Sm to get a raw timestamp (seconds since 1970). See man stat for more output options and format choices.

BTW, that command will list directories as well as files; for just files, add -type f at the right place:

find /useraccount/documents -type f -exec stat -f "%N %Sm" {} +
answered Mar 26, 2014 at 16:19
0
0

You can do this using the du command in the terminal. See the following discussion for a more detailed explanation:

List directories and their sizes in Mac OS X command line

answered Mar 26, 2014 at 11:04
1
  • I tried this command but I could not find a way to get time stamp of the files. Commented Mar 26, 2014 at 15:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.