Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Foreach question

As a CityDesk newbie (and a newbie to scripting, for that matter), I'm wondering if I can do the following, which is intended to cycle through the four specified folders, ignoring the index files in each:

{$ foreach x in (or (folder "Family") (folder "Baseball") (folder "Photos") (folder "Cycling")) (and (not(keyword_contains "Index"))) $}

It seems to work fine on a single folder as follows:

{$ foreach x in (and(folder "Baseball") not (keyword_contains "Index")) SortDescendBy .fileddate $}

By the way, I'm looking for some CityDesk "best practices" with respect to the pros and cons of organizing/classifying content using folders versus keywords. Obviously I'm trying the former, but maybe I'm going to run into some limitations using this approach?

Thanks in advance for you help.

Scott McDonald
Thursday, August 22, 2002

The shortest script is a "foreach x in all ..."

That will cover all your folders.  Other forum folks may help you with your "or" or "and" conditions.

Check out the tips to the left too.

Check this out for file/keyword site organization:

Thursday, August 22, 2002

I think the 'and' needs to go at the front. In English, what you're trying to say is (and (in one of the folders) (not an index page)).

Darren Collins
Thursday, August 22, 2002

Yes, you're right. The "and" does need to lead here, as in:

{$foreach x in (and (all) (not(keyword_contains "Index")))$}

Thanks again. Off I go!

Scott McDonald
Thursday, August 22, 2002

not quite -- (and (all) x) will always return all files, because you're saying "the set of all files AND the set of files matching x"

I think you just want (foreach x in (not (keyword-contains "index"))) ... assuming you're using keywords ... or even (foreach x in (not filename "index"))

Joel Spolsky
Thursday, August 22, 2002

*  Recent Topics

*  Fog Creek Home