Create Directory with Multiple subs?

Discuss and share scripts and script files...
highend
Posts: 9066
Joined: 06 Feb 2011 00:33

Re: Create Directory with Multiple subs?

Post by highend » 22 Jun 2020 17:36

And why exactly doesn't the script work for you in that case?

Go into the folder where you want to create "P18943", run the script, paste "P18943" in the little that popped up, done...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

kotlmg
Posts: 267
Joined: 30 Jun 2010 17:14

Re: Create Directory with Multiple subs?

Post by kotlmg » 22 Jun 2020 17:39

is there any wrong in the following script?

Code: Select all

 $dstPath = "D:\AVI\images\";
    $subFolders = $date+datediff($time,<date YYYY-MM-DD> ,"d")|$date+datediff($time,<date YYYY-MM-DD> ,"d")-1|$date+datediff($time,<date YYYY-MM-DD> ,"d")+1;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";

	



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

Re: Create Directory with Multiple subs?

Post by highend » 22 Jun 2020 18:06

"$dstPath\$folderName\$subFolder"
Do you really think that this will be a valid path if $dstPath already ends with a backslash? Surely not.

$subFolders = ...
No concatenation, not using strings...

Missing }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

galtar53
Posts: 9
Joined: 19 Nov 2019 16:33

Re: Create Directory with Multiple subs?

Post by galtar53 » 23 Jun 2020 11:10

highend wrote:
22 Jun 2020 17:36
And why exactly doesn't the script work for you in that case?

Go into the folder where you want to create "P18943", run the script, paste "P18943" in the little that popped up, done...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
    }

yes it works well but it makes me only one folder each time, what I want: to make me several folders at the same next time, the script asks me "Enter the desired folder name", only one but if I have a lot file following a list I already have. what do I have to do?
Attachments
Capture2.JPG
Capture2.JPG (15.7 KiB) Viewed 310 times

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

Re: Create Directory with Multiple subs?

Post by highend » 23 Jun 2020 11:55

Ok, I guess this is what you are looking for...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
        }
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

galtar53
Posts: 9
Joined: 19 Nov 2019 16:33

Re: Create Directory with Multiple subs?

Post by galtar53 » 23 Jun 2020 13:28

highend wrote:
23 Jun 2020 11:55
Ok, I guess this is what you are looking for...

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Parcellaire|Enquête Juridique";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
        }
    }

Thank you very much it's great, it works very well, the only thing I have left and how to drag the files that have the same name as the directories inside the parent folder and especially inside the sub-folder "Enquête Parcellaire". see my old message of June 22, 2020 5:21 p.m.
Attachments
capture1.JPG
capture1.JPG (30.37 KiB) Viewed 301 times

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

Re: Create Directory with Multiple subs?

Post by highend » 23 Jun 2020 13:37

Sorry but I don't understand the question...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

galtar53
Posts: 9
Joined: 19 Nov 2019 16:33

Re: Create Directory with Multiple subs?

Post by galtar53 » 23 Jun 2020 15:27

highend wrote:
23 Jun 2020 13:37
Sorry but I don't understand the question...

I mean: I Have several files named "P18943-Minute-PV.pdf"; "P18943-ZN2.pdf"; "P18943-Plan.pdf"; "P18943-Plan.dxf" either drag into their directory name "P18943" and especially in the subfolder "Enquête Parcellaire". the attached image will explain the result to you.


Thank you for your corporation
Attachments
Capture4.JPG
Capture4.JPG (24.36 KiB) Viewed 291 times

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

Re: Create Directory with Multiple subs?

Post by highend » 23 Jun 2020 15:30

Drag = Manual operation.

You mean "move" (something that can be done automatically via scripting)?

In other words, you want all files in the root directory with the same leading part (everything before the first "-") be moved into
<leading part folder>\Enquête Parcellaire

automatically without any user intervention?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

galtar53
Posts: 9
Joined: 19 Nov 2019 16:33

Re: Create Directory with Multiple subs?

Post by galtar53 » 23 Jun 2020 15:36

highend wrote:
23 Jun 2020 15:30
Drag = Manual operation.

You mean "move" (something that can be done automatically via scripting)?

In other words, you want all files in the root directory with the same leading part (everything before the first "-") be moved into
<leading part folder>\Enquête Parcellaire

automatically without any user intervention?

Yes exactly, I want to drag it automatically because I have a lot of different files and I can't do that manually.

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

Re: Create Directory with Multiple subs?

Post by highend » 23 Jun 2020 15:47

move not drag^^

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Juridique|Enquête Parcellaire";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    setting "BackgroundFileOps", 0;
    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
            $filesToMove = regexmatches($allFiles, $srcFolder . "-.*?(?=\r?\n|$)", <crlf>);
            $filesToMove = regexreplace($filesToMove, "^(.)", "$dstPath\$1");
            moveto "$dstPath\$srcFolder\" . gettoken($subFolders, 2, "|"), $filesToMove, , 1, 2;
        }
    }
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

galtar53
Posts: 9
Joined: 19 Nov 2019 16:33

Re: Create Directory with Multiple subs?

Post by galtar53 » 23 Jun 2020 15:54

highend wrote:
23 Jun 2020 15:47
move not drag^^

Code: Select all

$dstPath = <curpath>;
    $subFolders = "Enquête Juridique|Enquête Parcellaire";

    $allFiles = listpane(, , 1+4, <crlf>);
    // Use only those that follow a pattern
    $srcFolders = regexmatches($allFiles, "^.+?(?=-)", <crlf>);
    // Remove duplicates
    $srcFolders = formatlist($srcFolders, "sed", <crlf>);

    setting "BackgroundFileOps", 0;
    if ($srcFolders) {
        foreach($srcFolder, $srcFolders, <crlf>, "e") {
            foreach($subFolder, $subFolders, , "e") {
                if (exists("$dstPath\$srcFolder\$subFolder") != 2) {
                    new("$dstPath\$srcFolder\$subFolder", "dir", , "u");
                }
            }
            $filesToMove = regexmatches($allFiles, $srcFolder . "-.*?(?=\r?\n|$)", <crlf>);
            $filesToMove = regexreplace($filesToMove, "^(.)", "$dstPath\$1");
            moveto "$dstPath\$srcFolder\" . gettoken($subFolders, 2, "|"), $filesToMove, , 1, 2;
        }
    }
thanks a lot, it works well

kotlmg
Posts: 267
Joined: 30 Jun 2010 17:14

Re: Create Directory with Multiple subs?

Post by kotlmg » 23 Jun 2020 16:02

kotlmg wrote:
22 Jun 2020 17:39
is there any wrong in the following script?

Code: Select all

 $dstPath = "D:\AVI\images\";
    $subFolders = $date+datediff($time,<date YYYY-MM-DD> ,"d")|$date+datediff($time,<date YYYY-MM-DD> ,"d")-1|$date+datediff($time,<date YYYY-MM-DD> ,"d")+1;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";

	


highend, can you check the above code please?

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

Re: Create Directory with Multiple subs?

Post by highend » 23 Jun 2020 16:10

One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

kotlmg
Posts: 267
Joined: 30 Jun 2010 17:14

Re: Create Directory with Multiple subs?

Post by kotlmg » 23 Jun 2020 17:15

i am able to create folders with dates. but yeasterday and tomorrow i am not able to add

Code: Select all

$dstPath = "D:\AVI\images";
    $subFolders = new <datec yyyy.mm.dd>|new <datec yyyy.mm.dd>|new <datec yyyy.mm.dd>;

    $folderName = input("Enter the desired folder name");
    if ($folderName) {
        foreach($subFolder, $subFolders, , "e") {
            new("$dstPath\$folderName\$subFolder", "dir");
        }
        goto "$dstPath\$folderName";
  }


Post Reply