Running all macros in a folder

Running all macros in a folder

Anonymous
Not applicable
1,504 Views
6 Replies
Message 1 of 7

Running all macros in a folder

Anonymous
Not applicable

In an effort to clean up some of my macro paths/etc I would like to incorporate a "run all in folder" sort of command.

 

I have no idea how to practically impliment this.

 

The macros in question are labeled by number eg;

 

1-Run this

2-Run that 

3-Run this too

77-This as well

 

Right now I have a file named "1000-Run all" that I tend to incorporate and manually assign file locations to it within the macro file but this is INCREDIBLY tedious and inflexible.

 

The end goal is basically;

 

-List all the files in this directory in alphabetical order

-For each $file ; macro $file

 

Im wording this really poorly but help is appreciated. I am getting REALLY tired of updating a bunch of directories by hand.

 

 

0 Likes
Accepted solutions (2)
1,505 Views
6 Replies
Replies (6)
Message 2 of 7

rafael.sansao
Advisor
Advisor
Accepted solution
STRING $dir = "C:\dcam\config\macros"
STRING LIST $files = sort(list_files("files",$dir,".mac"))

FOREACH mac IN files {
	MACRO $mac
}

Rafael Sansão

OptiNC - www.optinc.tech

EESignature

Message 3 of 7

Anonymous
Not applicable

I've encountered a very similar problem.

 

Am I able to open powermill projects this way?

 

STRING $dir = THEDIRECTORY\"
STRING LIST $files = sort(list_files("files",$dir,".pmlprj"))

FOREACH pmlprj IN files {
	FORM RIBBON BACKSTAGE CLOSE PROJECT RECOVERY OPEN PROJSELECTOR
	$pmlprj
}

I've been hacking away at it but frankly it's a bit above my head.

0 Likes
Message 4 of 7

kukelyk
Advisor
Advisor

try this:

FOREACH pmlprj IN files { //FORM RIBBON BACKSTAGE CLOSE 
PROJECT RECOVERY OPEN $pmlprj
}

 

0 Likes
Message 5 of 7

Anonymous
Not applicable

That seems to do the trick though I may have tripped myself up with my own file structure.

 

In my case it is P:\Power Mill\Update\

 

There are many sub-folders within this folder eg;

 

 

P:\Power Mill\Update\Plate1\Plate1set1\plate1set1.pmlprj

 

Is there a way I can set it to look through all the folders within that folder?

 

0 Likes
Message 6 of 7

kukelyk
Advisor
Advisor
Accepted solution

list list_files( string flags, string dirpath[, string filetype])
Returns a list of files in the dirpath that optionally matches the filetype. flags can be either "all" (return files and directories), "files" (return just files), or "dirs" (return just directories). If flags ends with "+" then files in subdirectories are also returned.

 


Message 7 of 7

Anonymous
Not applicable

Outstanding.

 

 

I don't know if you are familiar with the existential dread associated with making a few minor tweaks on a thousand plates but you have saved me from it.