• 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: (resend)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (resend)


  • Subject: Re: (resend)
  • From: "Mark J. Reed" <email@hidden>
  • Date: Sat, 27 Mar 2010 08:42:28 -0400

To sum up:

ls file1 file2 file3

with no options just displays the filenames that you gave it -
assuming each file actually exists and isn't a folder.

ls folder1 folder2 folder3

shows the contents of each of the folders.

If you mix and match, you'll get a list of the files followed by the
contents of the folders.  With the -d option:

ls -d folder1 folder2 folder3

ls treats the folders as if they were files - it displays their names
instead of the contents.

You can combine these with the fact that the shell will expand wildcards.

ls -folder/*

bash expands that to a list of matching files, so what actually gets run is

ls folder/file1 folder/file2  folder/subfolder1 folder/file3 folder/subfolder2

which is the the mix-and-match case above.  You can pass -d to avoid
listing the contents of the subfolders.

If you add / to the wildcard, it only matches subfolders:

ls -d folder/*/

turns into

ls -d folder/subfolder1/ folder/subfolder2/

which will output

folder/subfolder1 folder/subfolder2

if you just want the "subfolder1" part without the leading folder
name, the easiest way to do that is to cd into the folder first.

cd folder && ls -d */

Adding -1 just causes each listed file to be on its own line, and the
-t causes them to be sorted by time.

I thought you wanted actual file objects, not just strings, and 'POSIX
file "blah"' won't work if "blah" is not the whole pathname, which is
why I took pains in my previous solutions to make sure that the output
*did* include the path to the starting folder.

I apologize for the confusion.






ls folder/*/

that
 _______________________________________________
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: 
 >Re: (resend) (From: Shane Stanley <email@hidden>)
 >Re: (resend) (From: Alex Zavatone <email@hidden>)
 >Re: (resend) (From: "Mark J. Reed" <email@hidden>)
 >Re: (resend) (From: Alex Zavatone <email@hidden>)
 >Re: (resend) (From: Skeeve <email@hidden>)
 >Re: (resend) (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: (resend)
  • Next by Date: Re: Rep: old script fails AND BUG in Smile 3.5.2 (build 609)
  • Previous by thread: Re: (resend)
  • Next by thread: Re: (resend)
  • Index(es):
    • Date
    • Thread