Re: Shell script to get a list of all subfolders inside a folder
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