Author Topic: File find  (Read 17795 times)

amenu

  • Newbie
  • *
  • Posts: 3
    • View Profile
File find
« on: September 14, 2015, 06:09:21 »
I just started using MC and am learning as I go along. I wanted to use file find to find filenames that had both of two words in them -- i.e., word1 and word2, not word1 or word2. I looked in the online documentation but did not see the answer. Where can I find this information.
-- Arthur

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 555
  • Old Skull
    • View Profile
Re: File find
« Reply #1 on: September 14, 2015, 09:51:27 »
Probably you should use RegEx like
Code: [Select]
(.*)(word1)(.*)(word2)(.*)to search for word1 followed by word2

or
Code: [Select]
(.*)(word1|word2)(.*)(word2|word1)(.*)to ignore order
« Last Edit: September 14, 2015, 10:10:57 by Jungle »

amenu

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: File find
« Reply #2 on: September 15, 2015, 02:32:40 »
I am not familiar with RegEx codes. Where is there an instruction manual where I can learn how to use RegEx?
-- Arthur

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 555
  • Old Skull
    • View Profile
Re: File find
« Reply #3 on: September 15, 2015, 06:34:42 »
Basic info coud be found here

amenu

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: File find
« Reply #4 on: September 15, 2015, 07:42:39 »
I've looked at the Wikipedia article and have a sense of how RegEx works. Would not the second expression you gave:

Code: [Select]
(.*)(word1|word2)(.*)(word2|word1)(.*)

select the files I am looking for (files that have both word1 and word2 in any order in their filenames) but also select files with two occurrences of word1 and no occurrences of word2, or two occurrences of word2 and no occurrences of word1?

I am thinking ((.*)(word1)(.*)(word2)(.*))|((.*)(word2)(.*)(word1)(.*)) would give me just those files that have both word1 and word2 in any order in their filenames.

I am ready to be corrected, as I am obviously unschooled in RegEx.
-- Arthur

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 555
  • Old Skull
    • View Profile
Re: File find
« Reply #5 on: September 15, 2015, 08:54:50 »
You're probably right.

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 514
    • View Profile
Re: File find
« Reply #6 on: September 15, 2015, 13:55:17 »
This is a useful free regex tester
http://antix.co.uk/Projects/Regex-Tester

If you want to go further with Regex this is a good place to look
http://www.regular-expressions.info/jgsoft.html
Some good regex progs as well (but paid-for).

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4488
    • View Profile
    • Multi Commander
Re: File find
« Reply #7 on: September 15, 2015, 17:55:24 »
I'm not an expert in RegEx

but this worked for me..  it requires that that word1 and word2 exist in the file in both orders (first word1 and then word2, or word2 and then word1)
Might get messy if more then two is used. But there must be some better regex trick for that

(.*word1.*word2.*|.*word2.*word1.*)