Tuesday, January 17, 2017

#1 2005-10-12 07:05:24 am

julifos
Administrator
From: MalasaƱa, Madrid
Registered: 2002-11-20
Posts: 2014

How can I search for specific items in a folder?

You can ask the Finder for specific items within a folder. You can specify several "filters" to match the files, such as its modification date, name or label. You can ask for any item, only for files, folders or even "internet location files" (those with extension ".webloc"). Finally, you can also tell the Finder to search for items in nesteed folders using the "entire contents" property. Some examples:

Find any item containing "as" in its name:

Applescript:

set theFolder to alias "path:to:dir:"

tell application "Finder"
   items of theFolder whose name contains "as"
end tell

Find any file older than a year:

Applescript:

files of theFolder whose creation date > ((current date) - (365 * days))

Find "internet location files" is any place of theFolder's hierarchy:

Applescript:

internet location files of entire contents of theFolder

Find files with extension ".txt" and label 3 (whatever is this color in your system):

Applescript:

files of theFolder whose name extension is "txt" and label index is 3

Take a look to the Finder's dictionary for more properties (which you can use to ask for items).

If you are a experienced shell scripter, you can utilize as well a "do shell script" call and use some *nix tools, such as ls or find, in combination with grep, sed or awk.


Filed under: Finder

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.037 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)