Quantity of same file on Drive X:

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Quantity of same file on Drive X:

Post by chincherpa »

Hi,

I have a folder with some files on Drive D:.
Now, I need to know of each file, how often it is present in Drive X:.

Same filenames = MATCH!

I thought about a CustomColumn, triggered by click or list (preferred solution, but slower??)
OR
in a result window, similar to the report window.

Maybe like this:

Code: Select all

Filename:       quantity:
image001.jpg     1
image002.jpg     1
image003.jpg     2
image004.jpg     0
How would I do that? :D

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

That depends. It makes more sense for a single file to just return it's count in that cc when you click
on it.

If you want to do it for all files, just use a script that shows the result in a window...
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

Ok, but my knowledge is unfortunately insufficient to do so. :)
May be you can give me a hint?

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

For which of these options?
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

I choose:
a script that shows the result in a window...
Thank you!

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

Are your source files all of the same extension?
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

yes

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

Something like this should work (and I've created it in a way that the src folder
can contain files with more than one extension as well)...

Code: Select all

    $src = "D:\here are the files we want to check";
    $dst = "X:\";

    // Get all file extensions
    $srcFiles = listfolder($src, , 1+4, <crlf>);
    $extensions = "*" . regexmatches($srcFiles, "\.\w+$", ";*");
    $extMatches = quicksearch($extensions, $dst, , "s");

    // Loop over all src files
    $results = "Quantity:     Filename:<crlf>";
    foreach($item, $srcFiles, <crlf>, "e") {
        $escaped = regexreplace($item, "([\\.+(){\[^$])", "\$1");
        $matches = regexmatches($extMatches, $escaped, , 1);
        $count = gettoken($matches, "count", "|");
        $results = $results . $count . strrepeat(" ", 14 - strlen($count)) . $item . <crlf>;
    }
    text $results;
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

Works best, thank you!
And thanks for your time!

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

Could you please explain me these two lines:

Code: Select all

        $escaped = regexreplace($item, "([\\.+(){\[^$])", "\$1");
        $matches = regexmatches($extMatches, $escaped, , 1);

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

Each file name needs to be escaped so that I can search for it via a regular expression
(it's the fastest method to generate the necessary count) inside the list of all found items
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

Hi,

exactly 1 year later...

How would be the CustomColumn-solution?

:biggrin: :D
Last edited by chincherpa on 14 Nov 2018 14:33, edited 1 time in total.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Quantity of same file on Drive X:

Post by highend »

Code: Select all

Snip: CustomColumn 1
  XYplorer 19.30.0025, 14.11.2018 14:28:26
Action
  ConfigureColumn
Caption
  Count
Type
  3
Definition
      $dst = "X:\";
  
      $extMatches = quicksearch("*.<cc_ext>", $dst, , "s");
      $escaped = regexreplace(<cc_name>, "([\\.+(){\[^$])", "\$1");
      $matches = regexmatches($extMatches, $escaped, , 1);
      return gettoken($matches, "count", "|");
Format
  1
Trigger
  2
Item Type
  0
Item Filter
  
One of my scripts helped you out? Please donate via Paypal

chincherpa
Posts: 37
Joined: 13 Dec 2016 10:58
Location: Stuttgart, Germany

Re: Quantity of same file on Drive X:

Post by chincherpa »

Oh, wow,
that was fast!

Thank you highend :)

Post Reply