• 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: Shell script to get a list of all subfolders inside a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell script to get a list of all subfolders inside a folder


  • Subject: Re: Shell script to get a list of all subfolders inside a folder
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 13 Oct 2015 21:55:07 +0200

> Le 13 oct. 2015 à 13:08, Shane Stanley a écrit :
>
> […]
> It's an easy enough assumption to make -- but I'd argue that's just another reason not to make it. Mac OS is built on Unix, but the stuff on top is also important.

Yes.


> […]
> Honestly, I think this a case of finding yourself in a hole, and trying to dig your way out.

No, just trying to reply to the original question: a shell script, return a list of HFS paths of directories.


>  First, it’s fraught with peril.

Assuming I’m knowing what I’m supposed to put into some directory of interest, what kind of peril could I be overlooking?


> And second, it’s very inefficient because even if you manage to add every possible extension to your regex pattern, find is still going to traverse all those unnecessary directories.

The "-prune" primary is supposed to avoid such traversals.


> So when I run your script on my home folder, it takes just under 70 seconds. Ouch.

Throughout this thread, I performed my tests on a folder containing about 810000 files and 80000 directories.

Running your first version of getFoldersIn (the one without BridgePlus) on it, slightly amended so as to return a list of posix paths instead of a list of file references, it returns 62335 items in 170-190 seconds.

To get exactly the same result set, I have to run:

	set AppleScript's text item delimiters to {return}
	set mylist to text items of (do shell script "/usr/bin/find -E " & myfolder & " -type d \\( \\( -iregex '.*\\.(xcodeproj|deps|nib|app|pbproj|fs|ppp|workflow|xcode|xcdatamodel|pkg|bundle|lpdf|kext|dSYM|wdgt|settings|trace|Patch|split)$' -and -prune \\) -or -print \\)")

That requires 30-40 seconds (with the loop for building a list of HFS paths, add 15 seconds).


Axel


 _______________________________________________
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


  • Follow-Ups:
    • Re: Shell script to get a list of all subfolders inside a folder
      • From: Shane Stanley <email@hidden>
References: 
 >Shell script to get a list of all subfolders inside a folder (From: Bert Groeneveld <email@hidden>)
 >Re: Shell script to get a list of all subfolders inside a folder (From: Axel Luttgens <email@hidden>)
 >Re: Shell script to get a list of all subfolders inside a folder (From: Shane Stanley <email@hidden>)
 >Re: Shell script to get a list of all subfolders inside a folder (From: Axel Luttgens <email@hidden>)
 >Re: Shell script to get a list of all subfolders inside a folder (From: Shane Stanley <email@hidden>)

  • Prev by Date: Find out in which subfolder a given file resides
  • Next by Date: Re: Find out in which subfolder a given file resides
  • Previous by thread: Re: Shell script to get a list of all subfolders inside a folder
  • Next by thread: Re: Shell script to get a list of all subfolders inside a folder
  • Index(es):
    • Date
    • Thread