• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: List content of a folder, output to document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: List content of a folder, output to document


  • Subject: Re: List content of a folder, output to document
  • From: Thomas Fischer <email@hidden>
  • Date: Wed, 6 Jan 2010 10:32:06 +0100

Hi,

I've been struggling with this kind of question for a while (see thread "Resolving an alias"), because different ways to select folders and files (e.g. by drag and drop, ask file or folder) give you different objects to deal with (finder items, items, aliases…).
Anyway, I finally decided to use the Satimage Osax instead (it's free!). This provides a convenient function "list files":

list files v : make a list of the files contained in the folder
list files alias : a folder
[recursively boolean] : default: true. If false, list files and folders.
[invisibles boolean] : default: false
[of extension list of string] : the required file extension(s)
[not conforming to list of string] : the forbidden Universal Type Identifier(s) (UTI)
[after date] : list only files whose modification date is after the after date parameter
[before date] : list only files whose modification date is before the before date parameter
[names only boolean] : allowed only with recursively false. Default: false
[as type] : string (URL), alias, unix path, path...
→ list of string or list of alias

I use this somewhat like this so collect PDF files:
tell application "Finder"
repeat with theFile in theList
set myProperties to properties of theFile
if class of myProperties is folder then
tell me to set theFiles to theFiles & (list files theFile of extension "pdf")
else if kind of myProperties contains "PDF" then
copy theFile to the end of theFiles
end if
end repeat
end tell

I hope this is of help.

All the best
Thomas

Am 05.01.2010 um 23:37 schrieb Inge Eidem:

Hi

Can you help me?
I need to get a folder´s content/items to be listed in a file for archiving.

I want to choose a folder and get the context menu on the folder to run the script, after starting the script ill end up with a file containing filnames, subfolders and filenames as a list in a text document. Is this possible?

This is what i hope to get in the file:

/index.html
/subfolder1/image.jpg
/file2.txt
/subfolder2/subsubfolder1/meta.qsl

I tried to get spotlight metadata but it was just not what i wanted as output.

Something like this??
tell application "Finder"
try
set filesList to files of sourceFolder as alias list
on error
set filelist to files of sourceFolder as alias as list
end try
end tell


Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
References: 
 >List content of a folder, output to document (From: Inge Eidem <email@hidden>)

  • Prev by Date: Re: Use AS operators dinamically
  • Next by Date: RE: AppleScript-Users Digest, Vol 7, Issue 10
  • Previous by thread: Re: List content of a folder, output to document
  • Next by thread: Re: List content of a folder, output to document
  • Index(es):
    • Date
    • Thread