Page 2 of 5

Re: Miscellaneous - Questions

Posted: 20 May 2019 23:09
by MaxEnrik
I give up, thanks.

Re: Miscellaneous - Questions

Posted: 20 May 2019 23:21
by highend
Answering the question would have been better...

Code: Select all

renameitem(gpc(<curpath>, "file") . <clipboard>, <curpath>);
No $parent...^^

Re: Miscellaneous - Questions

Posted: 20 May 2019 23:40
by MaxEnrik
You ^^. Now I can :biggrin:
I just need to mention, I started off to use ahk after 3 days @jupe mentioned about that. And today 254 lines of code.

Image

But I didn't wrote down single line code in XY by myself. That is terrible, huge consuming of time but even no single line of code.
Unfortunately, I absolutely don't understand XY scripting until today.

Thanks a lot, ^^

Re: Miscellaneous - Questions

Posted: 20 May 2019 23:51
by highend
XY is (like AHK) a scripting language. Don't see any difference there.

It just makes no sense to try to rename the parent of the current path when you actually want to rename the current path.

Programming is about logic. The rest is help file reading and statement construction. AHK is in no way easier than XY (and
I know what I'm talking about, I'm using AHK for years as well)...

Re: Miscellaneous - Questions

Posted: 21 May 2019 00:06
by MaxEnrik
This is time I spent for my currently issue, and I spent my time in the help.pdf and tried study your script (before you helped me) because it is similar issue.

Image
(mini - is meaning tree)

I hope I will write down next script by myself. (I will celebrate it, IF I will do it)
Thanks a lot, sir. Highly appreciate that.

Re: Miscellaneous - Questions

Posted: 26 May 2019 12:50
by MaxEnrik
#4 Creating Incremental Folders

Image

My goal to Create 10 Folders.
Selected Folder name: `Prefix-120-`
Need to Created Folders will look like this:

  • 01. Prefix-121-
    02. Prefix-122-
    03. Prefix-123-
    ...
    10. Prefix-130-
All code source from @highend
I just give it a try to achieve my goal.

Code: Select all

    $dstPath = <curpath>;
    $subFolders = "Folder-121-|Folder-122-"; ' No idea for incremental folder names

    $folderName = gpc(<curitem>, "component", -2, 1);
    if ($folderName)
    {
        foreach($subFolder, $subFolders, , "e")
        {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
    }
I am just laughing my scripting knowledge. :titter:
But still trying...

Re: Miscellaneous - Questions

Posted: 26 May 2019 12:58
by highend
Mh?

Give a real world example, so that I can see what the real prefix is and if there comes anything after
Prefix-<number>-

Re: Miscellaneous - Questions

Posted: 26 May 2019 13:11
by MaxEnrik
Something like below. And only words no `Symbols, `Numbers in this case.
Prefix is:
  • Sport
    Medical
    Health
    Do Fitness
(I used simple `Prefix because no complex `Named at first part of names)

Re: Miscellaneous - Questions

Posted: 26 May 2019 13:16
by highend
What does such a folder name now has to do with what you requested before?

Can you be a bit more damn specific? oO

Re: Miscellaneous - Questions

Posted: 26 May 2019 13:35
by MaxEnrik
Sorry. I don't understand your 1st question.

Currently real Folder Name is in my Drive: Medical-012-
So my goal to write a script to create 10 folders.
Medical-013-
Medical-014-
Medical-015-
Medical-016-
Medical-017-
Medical-018-
Medical-019-
Medical-020-
Medical-021-
Medical-022-

Re: Miscellaneous - Questions

Posted: 26 May 2019 13:37
by highend

Code: Select all

    $howMany = 10;

    $base     = gpc(<curitem>, "file");
    $startNum = trim(regexmatches($base, "-\d+?-"), "-");

    while ($i++ < $howMany) {
        $inc = "-" . ($startNum + $i) . "-";
        $newName = regexreplace($base, "-\d+?-", $inc);
        new($newName, "dir");
    }

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:12
by MaxEnrik
Thanks a lot man.

Just needed to do by myself, but I only found this `<#001> don't know how to combine it with this script to achieve my goal.
So problem is missing `0/zero as you see in the screenshot.
Is there a chance to do it like this? `013, 014, ..., 022

Image

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:14
by highend
Look up the format() command to get such a padding

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:19
by MaxEnrik
Wow, it worked. Thanks.

Code: Select all

        $inc = "-0" . ($startNum + $i) . "-";
Is this method right?

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:20
by highend
No, it isn't. I said "look up the format() command"...