File name / Folder name select

Discuss and share scripts and script files...
CookieMonster

File name / Folder name select

Post by CookieMonster »

I swore there was a script, that did the following. When selecting a file, any matching folders with an identical name to the file name get selected as well.

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: File name / Folder name select

Post by highend »

Code: Select all

    foreach($folder, listpane( ,"*", 6)) {
        if ("<curbase>" == $folder) {
            selectitems $folder, , 0, "a";
        }
    }
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

When I select the file, then run the script, the folder with close to the exact same name is not selected ?

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: File name / Folder name select

Post by TheQwerty »

CookieMonster wrote:folders with an identical name to the file name get selected
CookieMonster wrote:folder with close to the exact same name is not selected ?
Sounds like you need to take some time to think about what it is you're trying to accomplish.

highend
Posts: 13311
Joined: 06 Feb 2011 00:33

Re: File name / Folder name select

Post by highend »

Sounds like you need to take some time to think about what it is you're trying to accomplish.
...

One of the most important features of the forum software? *g*o*e a user... :whistle:
One of my scripts helped you out? Please donate via Paypal

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

I have a file called 'Acme198' there is a folder called 'Acme198-files' when I select the file 'Acme198' I want the respected folder 'Acme198-files' to be selected as well, which goes for dozens of other files of similarity.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: File name / Folder name select

Post by TheQwerty »

Code: Select all

::rtfm('idh_scripting.htm#idh_scripting_comparisons');
Try reading that and seeing if you can figure it out on your own.

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

If the file is equal to the folder then select the folder, all wrapped in a loop. This is exactly how I want the script to work. Although when I select the file(s) the related folders(s) are not selected ?

RalphM
Posts: 1935
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: File name / Folder name select

Post by RalphM »

The Qwerty pointed you in the right direction for some reading and then YOU could try to adapt your changed comparison needs to the earlier script, ok?
And I'm sure if you at least try but can't get it to work straight away, you'll find somebody to help you with further questions.
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

I tried both boolean and NotEqualTo within the condition. When I select a file, for example <PaperWild567>.xxx then run the script all folders that have the same name <PaperWild> are selected instead of the folder(s) with the name <PaperWild567>

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("<filename>" != $folder) {
            selectitems $folder, , 0, "a";
        }
    }

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

I have a file called "acme19ze.<ext> I have a folder with the same name except it has -files appended to the folder name "acme19Ze-files" selecting the file "acme19ze.<ext>" then running the script, selects all the folders with the "-files" appended to the folder name, which is not what I want. The script should only select the exact folder name related to the file, in the example used that would be; "acme19ze.<ext>" and the folder "acme19Ze-files" only, not all the folders, which all have difference folder names with the only exception being the "-files" name is appended onto the folder name.

Code: Select all

foreach($folder, listpane( ,"*", 6)) {
        if ("<filename>" != $folder) {
            selectitems $folder, , 0, "a";
        }
    }

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: File name / Folder name select

Post by TheQwerty »

That section of help I linked to has more operators for comparing than just equal ('==') and not equal ('!='), why not experiment with the others until you find one you like?

CookieMonster

Re: File name / Folder name select

Post by CookieMonster »

The problem is not the operator, rather if the file name has letters or numbers, how do you add flexibility to the script whereas your not hard coding in any specific file name that includes letters or numbers, and leaving the script open. For example; acme19z I don't want the script to only search for folders with 19z I want to to be flexible, I hope that makes sense ? :)

BTW How did you get this link; I'm not fond of the Read the Fuc*** manual acronym, but oh well :)

::rtfm('idh_scripting.htm#idh_scripting_comparisons');

j_c_hallgren
XY Blog Master
Posts: 5824
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: File name / Folder name select

Post by j_c_hallgren »

CookieMonster wrote: I'm not fond of the Read the Fuc*** manual acronym, but oh well :)
For those who aren't familair with the usual values, it can be said as "the Fine" or "the Fabulous" or such -- or at least "the Friggin".
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: File name / Folder name select

Post by TheQwerty »

CookieMonster wrote:The problem is not the operator
Sure it is.

The example you've provided is you want to select acme19z.ext and have the script select acme19z-files - which means you want to select folders with names that start with or are like the selected file(s).

Based on your original description you only wanted to select folders with the same name as the selected file(s) - which is why highend's script tests for equality (==).

Your attempts thus far are only looking for folders with names that are not equal to the selected file(s) (!=) so I hope you understand why it would select notthefolderwewantselected since it does not equal acme19z.

The section I linked to includes 8 more operators that could be used, and I guarantee if you gave them all a try and followed the examples you'd eventually find one that you like, at least for the item names you've provided.

Monster wrote:BTW How did you get this link; I'm not fond of the Read the Fuc*** manual acronym, but oh well :)

::rtfm('idh_scripting.htm#idh_scripting_comparisons');
At the top of the page I right-clicked Comparisons in the page index and copied it from the Properties dialog.

Post Reply