#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0

    Iterate without string concatenation


    I need to iterate thru a list and avoid string concatenation

    /Risk/Emerald/Filters/100/pending

    in this case /risk/emerald/filters is constant. in the filters folder we have a variable number of folders could be just 1 could be a thousand or more.

    All folders will have the pending folder which is also constant.

    so you could have
    /Risk/Ozone/Filters/100/pending
    /Risk/Ozone/Filters/201/pending
    /Risk/Ozone/Filters/678/pending ... etc.

    I want to iterate thru these folders at runtime and get the values in the pending folder
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,929
    Rep Power
    481
    Looks like you're on a unix system. Use the command


    $ find /Risk/Ozone/Filters/ -exec myprogram {} \;

    find will substitute for {} the full path name which will be an argument to myprogram. Thus
    myprogram FILE
    will execute for each file. Python solutions I can think of are messier.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Looks like you're on a unix system. Use the command


    $ find /Risk/Ozone/Filters/ -exec myprogram {} \;

    find will substitute for {} the full path name which will be an argument to myprogram. Thus
    myprogram FILE
    will execute for each file. Python solutions I can think of are messier.
    Thanks a million

IMN logo majestic logo threadwatch logo seochat tools logo