# Mac OS problem

**URL:** <https://boards.straightdope.com/t/mac-os-problem/121442>\
**Category:** Factual Questions\
**Created:** [July 29, 2002, 10:45pm UTC](https://boards.straightdope.com/t/mac-os-problem/121442 "2002-07-29T22:45:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryanmcc](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bryanmcc](https://boards.straightdope.com/u/bryanmcc)\
**Post date:** [July 29, 2002, 10:45pm UTC](https://boards.straightdope.com/t/mac-os-problem/121442/1 "2002-07-29T22:45:26Z")

</div>

Hoping someone can help with this computer problem. In the Finder on a Mac, you can view the files in List mode, so that various stats are shown about them. One of these is file size. I have several thousand files, and I would like to be able to get this information out easilly. I need it in a text file, so that I can insert it into a MySQL database. Does anyone know a shortcut or trick that would allow me to do this?

-b

---

<div class="post-metadata">

**Author:** ![rackensack](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@rackensack](https://boards.straightdope.com/u/rackensack)\
**Post date:** [July 30, 2002, 4:41am UTC](https://boards.straightdope.com/t/mac-os-problem/121442/2 "2002-07-30T04:41:20Z")

</div>

There’s a little shareware program called, imaginatively enough, “List Files” that does what you want, and is fully configurable to include the info you want and not the info you don’t.

[http://download.com.com/3000-2238-866936.html?tag=lst-0-3](http://download.com.com/3000-2238-866936.html?tag=lst-0-3)

---

<div class="post-metadata">

**Author:** ![bryanmcc](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bryanmcc](https://boards.straightdope.com/u/bryanmcc)\
**Post date:** [July 30, 2002, 2:46pm UTC](https://boards.straightdope.com/t/mac-os-problem/121442/3 "2002-07-30T14:46:52Z")

</div>

Thanks **rackensack**! Almost perfect. Still, seems odd that there isn’t a Mac shortcut that would allow you to do the same thing…

-b

---

<div class="post-metadata">

**Author:** ![Mentor\_and\_Liar](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Mentor\_and\_Liar](https://boards.straightdope.com/u/Mentor_and_Liar)\
**Post date:** [July 30, 2002, 8:51pm UTC](https://boards.straightdope.com/t/mac-os-problem/121442/4 "2002-07-30T20:51:23Z")

</div>

It is trivial under OS-X. Open a terminal window and type "ls -l " drag the folder icon from the title bar of the relevent window to the command line (this will paste the path for you) type “| cat\>~/desktop/afilename.txt” and press return. Your file will appear, patiently waiting on your desktop. the command will look something like this:

ls -l /Macintosh\ HD/Users/yourname/yourfolder | cat\>~/desktop/thefilename.txt

I’m afraid this might be hard to read, it starts “el es space dash el” and the symbol before space cat is called “pipe” it’s shift-key-above-return. If you need to strip out some of the garbage, we can sed that out too, let me know.

---

<div class="post-metadata">

**Author:** ![Mentor\_and\_Liar](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@Mentor\_and\_Liar](https://boards.straightdope.com/u/Mentor_and_Liar)\
**Post date:** [July 30, 2002, 9:01pm UTC](https://boards.straightdope.com/t/mac-os-problem/121442/5 "2002-07-30T21:01:43Z")

</div>

It is trivial under OS-X. Open a terminal window and type "ls -l " drag the folder icon from the title bar of the relevent window to the command line (this will paste the path for you) type “| cat\>~/desktop/afilename.txt” and press return. Your file will appear, patiently waiting on your desktop. the command will look something like this:

ls -l /Macintosh\ HD/Users/yourname/yourfolder | cat\>~/desktop/thefilename.txt

I’m afraid this might be hard to read, it starts “el es space dash el” and the symbol before space cat is called “pipe” it’s shift-key-above-return. If you need to strip out some of the garbage, we can sed that out too, let me know.

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [July 31, 2002, 5:03am UTC](https://boards.straightdope.com/t/mac-os-problem/121442/6 "2002-07-31T05:03:08Z")

</div>

You can do it under MacOS 8 or 9 without any 3rd party software as well:

tell the application “Finder”  
activate  
set bryannmcc\_rept to “Size in Bytes”  
set myFolder to choose folder  
set myPath to myFolder as string  
set theItemNames to (list folder myFolder)  
repeat with thisName in theItemNames  
set theFullPath to alias (myPath & thisName)  
select theFullPath  
set theSelectedFile to selection  
set FileSize to data size theSelectedFile as string  
set theInfo to thisName & “–” & FileSize  
set bryannmcc\_rept to bryannmcc\_rept & "  
" & theInfo  
end repeat  
end tell

Stick that in your Script Editor!
