Author Topic: [SOLVED] Multi-script for create folders and subfolders from target windows  (Read 2438 times)

SG-1 Charpy

  • Newbie
  • *
  • Posts: 2
    • View Profile
hi, i would like to create an user command for create 2 folders (A16 and AGFT) and sub-folders from path of source windows:
Here my initial folder (different each time i use the command):
For example, here my source path:
"C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\CM4000"
First create folder "A16"
Path is now
"C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\CM4000\A16"
Create folder "L" inside the folder A16
Path is: "C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\CM4000\A16\L"
Create inside another folder "LABART" inside the folder L
Path: "C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\A16\L\LABART"
Create inside another folder "CM4000"  inside the folder LABART
Path: "C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\A16\L\LABART\CM4000"
and doing the same for the folder AGFT
Path: "C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\L\LABART\AGFT\L\LABART\CM4000"
See attachement for more screenshot in order a1 to a5
Here the beginning of the script:
@var $path0 = GetSourceFocusPath();
@var $filename = 'C:\temp\Path.txt';
@var $format = 0;
SaveStringToFile( $filename, $path0, $format , 1);

After i can't trim the the path to create folder
Actually i use the create folder button for all the folders (use A16;AGFT;L;LABART;CM4000 command for it) and move the folder after
I think it's possible to make it easly with multi-script !
Thanks

                 
« Last Edit: November 06, 2024, 18:41:24 by SG-1 Charpy »

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 550
  • Old Skull
    • View Profile
Re: Multi-script for create folders and subfolders from target windows
« Reply #1 on: November 05, 2024, 20:56:41 »
Try this:
Code: [Select]
@var $current_dir = GetSourcePath();
@var $path_parts  = StrSplit( $current_dir, '\' );
@var $parts_count = arrayCount( $path_parts );

@var $i = $parts_count - 3;
@var $path_tail = "";

for( $i; $i < $parts_count; $i++ )
{
  $path_tail = $path_tail ^ $path_parts[$i];
}

MakeDir( $current_dir ^ 'A16'  ^ $path_tail, "LOCAL,RECURSIVE" );
MakeDir( $current_dir ^ 'AGFT' ^ $path_tail, "LOCAL,RECURSIVE" );

It is assumed that the source folder has at least 4 levels (x:\%LETTER%\%NAME%\CM4000)

SG-1 Charpy

  • Newbie
  • *
  • Posts: 2
    • View Profile
 ;D Wonderfull it's working perfectly !!!
i tried the StrSplit but not with the quotes '  >:(
And the source folder will always be:
C:\Users\Utilisateur\Documents\bSolid\PROGRAMMES\CHANTIERS\%LETTER%\%NAME%\CMXXXX)
Thanks Jungle, this will save me time in my work. I create programs for CNC with two different program and I inject them directly into the machines so that operators can use them after.
The post is for me solved.
« Last Edit: November 06, 2024, 18:43:15 by SG-1 Charpy »