The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   Applications (http://hintsforums.macworld.com/forumdisplay.php?f=5)
-   -   Any way to create a file listing of a folder to txt file? (http://hintsforums.macworld.com/showthread.php?t=48968)

ShatteredGlass 12-19-2005 06:33 PM

Any way to create a file listing of a folder to txt file?
 
I have a few folders that I would like to print the contents of (preferably send them to a text file for editing), is there any small app that will do that?

I've discovered how to send the contents of a folder to the printer or to a PDF file, but I'd like it to be editable. (ie, just have the file names in alpha order, without having the date, file size etc.

Is there any way to edit a PDF file without having to buy Adobe Acrobat?

hayne 12-19-2005 07:00 PM

Quote:

Originally Posted by ShatteredGlass
I have a few folders that I would like to print the contents of (preferably send them to a text file for editing), is there any small app that will do that?

You could just select-all in Finder, then copy and paste into a text editor window - e.g. TextEdit which you already have.

But the free text editor "TextWrangler" (www.bbedit.com) has a special menu item for showing a listing of a folder's contents.

voldenuit 12-20-2005 05:59 AM

...or you could do it the True Unix Way using Terminal:

cd /the/directory/to/list
ls > filelist.txt

replace /the/directory/to/list with the path to the real directory, you'll find a list of the files inside in the text file "filelist.txt" in the same directory.

bluehz 12-20-2005 06:15 AM

Not sure exactly when this changed in Mac OS, but when I select in Finder now and copy and attempt to paste in TextEdit, Mail, and others - the system attempts to paste the ACTUAL FILES. This is VERY ANNOYING considering for years, even pre-Mac OS X - the standard action was to copy the filenames not the actual files. The only way it actually works now - is if you make sure that the file you are pasting into is PLAIN TEXT... otherwise it will attempt to paste the actual file. And let me tell you - it will bog your machine something fierce when you try to paste 100 mp3 into a TextEdit document when what you really wanted was a text list of the mp3's.

Quote:

Originally Posted by hayne
You could just select-all in Finder, then copy and paste into a text editor window - e.g. TextEdit which you already have.


ShatteredGlass 12-20-2005 07:38 AM

Quote:

Originally Posted by voldenuit
...or you could do it the True Unix Way using Terminal:

cd /the/directory/to/list
ls > filelist.txt

replace /the/directory/to/list with the path to the real directory, you'll find a list of the files inside in the text file "filelist.txt" in the same directory.

Eeeek... t-t-t-t-terminal... u-u-u-unix??? I'm used to the old dos commands is unix similar? I guess it's time I head over to the unix section of this forum then. :)

ShatteredGlass 12-20-2005 07:41 AM

Quote:

Originally Posted by bluehz
<snip> is if you make sure that the file you are pasting into is PLAIN TEXT... otherwise it will attempt to paste the actual file. And let me tell you - it will bog your machine something fierce when you try to paste 100 mp3 into a TextEdit document when what you really wanted was a text list of the mp3's.

Yes, I found this was happening. I just discovered the option in preferences to make it plain text rather than rtf. Thanks!

voldenuit 12-20-2005 08:07 AM

Quote:

Originally Posted by ShatteredGlass
Eeeek... t-t-t-t-terminal... u-u-u-unix??? I'm used to the old dos commands is unix similar?

Unix has been around for more than 30 years, now guess who was "inspired" by whom...
Also note that the commands I suggested did never change their behaviour throughout the decades ;) .

frankko 12-20-2005 08:22 AM

Just to go back a bit... if anybody does have BBEdit (this might work in TextWrangler) all you have do is drag a folder into the editable area of a document and BBEdit will create a nested list of all directories, sub-directories, and files containted therein.

And you get get around bluehz's valid point by, after copying the "files", going to the Terminal and typing `pbpaste | pbcopy`. That'll strip out the references to the files, leaving you with just a plain text list. (The command also works for converting styled text to plain text.)

mark hunte 12-20-2005 10:02 AM

Quote:

Originally Posted by frankko
Just to go back a bit... if anybody does have BBEdit (this might work in TextWrangler) all you have do is drag a folder into the editable area of a document and BBEdit will create a nested list of all directories, sub-directories, and files containted therein.

Hey Nice, I can confirm it works in TextWrangler.

hayne 12-20-2005 01:35 PM

Quote:

Originally Posted by bluehz
Not sure exactly when this changed in Mac OS, but when I select in Finder now and copy and attempt to paste in TextEdit, Mail, and others - the system attempts to paste the ACTUAL FILES.

Okay - sorry, I guess I shouldn't have recommended using TextEdit for this. Instead use any text editor that restricts itself to handling text - e.g. TextWrangler. TextEdit is a useful program since it handles much more than plain text, but there is always a need for a program that is a plain text editor and nothing more.

nukular 12-20-2005 04:45 PM

I actually have an Applescript that does the same thing....I got it from some site or another. I think it works faster than pulling the directory into TextWrangler...but I could be wrong...that just seemed to work slowly.

property fileName : "File List.txt"

on run
choose folder with prompt "Get list of files from this folder:"
open {result}
end run

on open droppedItems
set ASTID to AppleScript's text item delimiters
tell application "Finder" to launch

repeat with thisItem in droppedItems
if (folder of (info for thisItem without size)) is true then
set AppleScript's text item delimiters to (ASCII character 13)
tell application "Finder" to set theList to entire contents of thisItem as text
set AppleScript's text item delimiters to ""

try
open for access file ((thisItem as text) & fileName) with write permission
set theFileRef to result

write theList to theFileRef
close access theFileRef
on error errorMsg number errorNum
try
close access theFileRef
end try
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
end if
end repeat

set AppleScript's text item delimiters to ASTID
return true
end open

mark hunte 12-20-2005 09:27 PM

I like the way textwrangler displays the listing of the folder contents

Here's two scripts for textwrangler,

If you select your folder in finder and run the first script.
It will list the contents of the folder but not sub folders.

the second script will give you the full break down

Code:

tell application "Finder"
        set selec to selection as alias
        set conta to container of selec as alias
       
        set item_Name to name of selec
end tell
tell application "TextWrangler"
        activate
       
        open conta
       
end tell


tell application "System Events"
        tell process "TextWrangler"
                keystroke item_Name
        end tell
end tell

Code:

tell application "Finder"
        set selec to selection as alias
       
        set conta to POSIX path of selec
       
end tell
tell application "TextWrangler"
        activate
        make new text document
        tell application "System Events"
                tell process "TextWrangler"
                        click menu item "Folder Listing…" of menu 1 of menu item ¬
                                "Insert" of menu 1 of menu bar item "Edit" of menu bar 1
                        keystroke "g" using {command down, shift down}
                        keystroke conta
                        repeat 2 times
                                keystroke return
                        end repeat
                end tell
        end tell
end tell


bluehz 12-21-2005 08:07 AM

Great idea frannko - I use Quicksilver so what I did was just create a shell script:
Code:

#!/bin/sh
pbpaste | pbcopy

named it "clean_clipboard", save it in ~/Library/Application Support/Quicksilver/Actions, and made it executable.

Now I can just make a selection in the Finder, invoke Quicksilver, and then "clean_clipboard" and voila. My clipboard contents are converted to plain text and ready to paste.

Quote:

Originally Posted by frankko
And you get get around bluehz's valid point by, after copying the "files", going to the Terminal and typing `pbpaste | pbcopy`. That'll strip out the references to the files, leaving you with just a plain text list. (The command also works for converting styled text to plain text.)


HazyJMac 03-31-2006 09:57 PM

Hey guys,
Was looking for a way to do something like this and stumbled across this thread. The terminal method works fine, but I was wondering if there was any way to print sub folders and their files as well.

Thanks for any input.

mark hunte 04-01-2006 05:57 AM

Quote:

Originally Posted by HazyJMac
Hey guys,
Was looking for a way to do something like this and stumbled across this thread. The terminal method works fine, but I was wondering if there was any way to print sub folders and their files as well.

Thanks for any input.

( not in terminal ) but Read post 12.

It does sub folders.
**here.
slight change.
Code:

tell application "Finder"
        set selec to (choose folder) as alias
       
        set conta to POSIX path of selec
       
end tell
tell application "TextWrangler"
        activate
        make new text document
        tell application "System Events"
                tell process "TextWrangler"
                        click menu item "Folder Listing…" of menu 1 of menu item ¬
                                "Insert" of menu 1 of menu bar item "Edit" of menu bar 1
                        keystroke "g" using {command down, shift down}
                        keystroke conta
                        repeat 2 times
                                keystroke return
                        end repeat
                end tell
        end tell
end tell

Also if you want to do it in terminal.

Code:

ls -F -R > list.txt; open list.txt
or
Code:

ls -R > list.txt; open list.txt
But I personally thing the applescript looks better.

OSXdude 07-11-2006 08:53 PM

A Classic Folder File Lister
 
Hello ShatteredGlass,

This response is a bit late, and perhaps you have already found a viable solution to your problem via one of the previous responses, but I did want to mention that if you are using a machine that can still run in Classic mode, that is, that has Mac OS9 installed on another hard drive or partition, there is a PPC-based file lister called "Catalogger 1.0", written by John Eriksson of "SwimpSoft". I have been using this program in Classic mode for a number of years now to list the almost 36,000 files on our file server. The program is simple, but offers a few options, such as how to indent the nested files and folders, etc.

However, there is one problem with this program: Being as it is an old PPC-based program, and not a true OSX-based, Cocoa program, any file names over 31 characters are truncated, and the remaining characters appear as garbage in the text file list. There is a carbonized version of the program, but it has a few GUI problems. I have written to John about this, and he informed me that he has no intentions of continuing work on Catalogger. It is for this reason that I am looking for an actual OSX-native program which will perform the same function. To date, I have not been able to find one.

If you are interested in Catalogger 1.0, you can probably find it in the OS8-9 section of VersionTracker, or on some other popular Mac download site...or I'd be happy to email a copy of it to you. I don't think that the file is very large.

OSXdude 07-11-2006 09:42 PM

Problem With Your AppleScript
 
Quote:

Originally Posted by nukular
I actually have an Applescript that does the same thing....I got it from some site or another. I think it works faster than pulling the directory into TextWrangler...but I could be wrong...that just seemed to work slowly.

Hello Nukular,

I just tried copying and pasting, and then running and/or compiling your script in the Apple Script Editor. Whenever I do so, Apple Script Editor reports an error in the following section:

repeat with thisItem in droppedItems
if (folder of (info for thisItem without size)) is true then
set AppleScript's text item delimiters to (ASCII character 13)

The word "without" is highlighted, and the error states "Syntax Error: Expected “, ” but found “without”. I am running Panther 10.3.9 on a G3 AV machine. Any ideas why I am being thrown this error?

Thanks!

OSXdude 07-11-2006 10:15 PM

Print List Without Invisible Files?
 
Quote:

Originally Posted by mark hunte
( not in terminal ) but Read post 12.

It does sub folders.
**here.
slight change.

But I personally thing the applescript looks better.

Hello Mark...Thank-you for the very practical script. I have been looking for something like this to replace the current Classic application I have been using on our Tiger machine which runs an FTP server.

I was wondering, however: Is there a way to tell the script to not print invisible files in the text file? I create a files list which our visitors can download from our FTP server, and they really don't need to see the invisible files that are on the server.

Thanks so much in advance!

ivansahba 11-18-2007 10:16 PM

Very Easy and Fast
 
I just came accross this and was not sure if you still want it.

Here is the trick with slight change.
There are no apps that I know for OS X but this is faster than any app you ever think of.

Open TEXTEDIT.
With a new blank document press COMMAND+SHIFT+T
Copy any folder contents even if it is 20GB (or 2TB). Paste it there.

If you do it in a regular page it will try to paste actual docs and files, folder contents and it goes to coma. But in Plain Text it can not paste anything but pure text.
I have seen a few scripts but they are crippled or slow. Forget about typing in Terminal.

OSXdude 11-19-2007 01:53 AM

Hello Ivansahba,

Well, I just tried your idea on one particular partition. However, it did not work. While it did paste in what I had copied, it only pasted the top level folders; it didn't copy over the subfolders within those top level folders, or the files and folders contained within those subfolders. Being as it didn't do that, I can't even tell if it would indent everything properly according to level, if it did work as I had hoped.

There is a program on VersionTracker, in the Tiger section I believe, which is close to doing what I want, but not quite. I can't remember the name of it at the moment, but I believe I may have written to the author, or possibly posted on his support forum, some suggestions for improving his app. Hopefully, he will consider adding the features, and we will all eventually have what we need.

Considering how long OSX has been out, one would think that such a practical tool would have been written and released long ago. It leaves me a bit puzzled that it hasn't.

Now, if I can just remember the name of that app. :)

capitalj 11-19-2007 12:08 PM

Quote:

Originally Posted by OSXdude (Post 426505)
Now, if I can just remember the name of that app. :)

Could it be one of these?

Print Window

PrintFinder

Sesquipedalian 07-30-2009 02:12 AM

Pardon the thread necromancy, but for the sake of anyone stumbling on this thread via Google:

Never mind all the crazy business mentioned above. Select all in Finder, then do a Paste and Match Style in TextEdit. That will paste the file names as a simple list of text.

AHunter3 07-31-2009 02:03 AM

Won't do a hierarchical folder listing, though, only the immediate contents of the folder.

The TextWrangler/BBEdit menu item will insert a folder's contents along with not only it subfolders but their contents including their subfolders and their contents and so on. Do your whole hard disk if you want, etc etc.

Be that as it may, it's great that in MacOS you can just select and do ⌘-C on files and paste in any text-savvy environment and it pastes the file names. That's not Windows-esque behavior so it's good to clue in the Windows switchers that you can do that.

baccasthebesteve 01-28-2010 12:51 PM

I've been trying to import the contents of a folder, and Textwrangler will give the file listings alphabetically and indent for subfolders, but I wanted to add a column that shows the dates modified for each file in the directory I import. Is there a way to do this?

CeeDubH 05-12-2010 12:55 AM

Just select Format/Make PLain Text (Or just hit Shift+CMD+T) and then drag and drop your files into Text Edit. Simple. :)

microfridge 06-01-2010 08:47 PM

I've been looking for the same sort of thing, but what's important is to get the entire path attached to the file name. For example, I don't just need index.html, which is on my desktop, but /Users/me/Desktop/index.html. Unfortunately it doesn't seem like any of the advice above does this for me.

Maybe there's a different solution though.

The purpose of this is so that I can do a batch file rename using the program A Better Finder Rename 7, which requires such a tab-delimited file containing a file list with full paths and their corresponding new file names.

Any advice would be greatly appreciated! I'm sure I can't be the only one with this sort of issue. :)

macosnoob 06-02-2010 04:39 PM

@microfridge

Open a TextEdit window. Format > Make Plain Text.

Drag in one or more files. If it's an entire folder, set the folder to List View, Select All, and drag files into the open TextEdit window. If there are subfolders, too, disclose them as well: Select All, Cmd-Opt-right arrow, Select All again, and drag to open TextEdit window.

microfridge 06-02-2010 04:46 PM

Quote:

Originally Posted by macosnoob (Post 584833)
@microfridge

Open a TextEdit window. Format > Make Plain Text.

Drag in one or more files. If it's an entire folder, set the folder to List View, Select All, and drag files into the open TextEdit window. If there are subfolders, too, disclose them as well: Select All, Cmd-Opt-right arrow, Select All again, and drag to open TextEdit window.

Thanks a bunch macosnoob, I could swear that didn't work the first time around -- it only gave me the filenames without the full path. But, it worked this time. Maybe I was sleepy when I tried it the first time.

Thanks!

Steinorama 10-30-2011 11:54 PM

Paste folder contents
 
"Any way to create a file listing of a folder to txt file?"

Yes.
Open folder.
Select all ( Command A )
Copy ( Command C)
Open Text Edit
Edit > Paste and Match Style ( Shift Option Command V )
:)


All times are GMT -5. The time now is 02:52 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.