• 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: Mon, 12 Oct 2015 17:19:31 +0200

> Le 12 oct. 2015 à 15:42, Bert Groeneveld a écrit :
>
> Hi, I need a list of all subfolders (HFS path, not just the name) that are inside a given folder.
> Can anyone help me with a shell script that does exactly the same as following Finder statement, which is very very slow (execution time 90 seconds for 2265 subfolders):
>
> set myfolder to alias “Macintosh HD:Users:bertus:Desktop:example folder"
>
> tell application "Finder"
> 	set mySubFolders to every folder of entire contents of myfolder
> end tell
>
> Hope someone can post example code. That would really help me. Unfortunately I am unable to figure this out myself.

Hello Bert,

Probably not the most efficient, but should be quicker than Finder’s "entire contents":

	property mylist : {}

	set myfolder to alias "Macintosh HD:Users:bertus:Desktop:example folder"

	set myfolder to quoted form of POSIX path of myfolder
	set AppleScript's text item delimiters to {return}
	set mylist to text items of (do shell script "/usr/bin/find " & myfolder & " -type d")
	repeat with i from 1 to length of mylist
		set item i of my mylist to (POSIX file (item i of my mylist) as text)
	end repeat

HTH,
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>)

  • Prev by Date: Shell script to get a list of all subfolders inside a folder
  • Next by Date: Re: Shell script to get a list of all subfolders inside a folder
  • Previous by thread: 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