re organizing macro changing the folder paths into the macro files. is it possible?

re organizing macro changing the folder paths into the macro files. is it possible?

info
Contributor Contributor
1,195 Views
17 Replies
Message 1 of 18

re organizing macro changing the folder paths into the macro files. is it possible?

info
Contributor
Contributor

hello

when I made my macros I has been used to put them intofolders nested a lot , (nesting them with long folder paths).

This was because I had to made groups of macros for eacn milling machine.

Now, Is there a software that can canges , into each of my macro text files, the path folders?

here a simple example I underlined what I have to change, the path folder:

 

I need to change this:

STRING ARRAY Choices[] = { "sbalzo 50", "applica HAIMER 100"}

INT C = INPUT CHOICE $Choices "6R1"
IF $C==0 {
MACRO "C:\pmill4\micromacro\MACRO_SGROSSATURA\VTR\6R1\6R1_sbalzo_50.mac"
} ELSEIF $C==1 {
MACRO "C:\pmill4\micromacro\MACRO_SGROSSATURA\VTR\6R1\APPLICA_PINZA_HAIMER.mac"
}

 

 

 

into this:

STRING ARRAY Choices[] = { "sbalzo 50", "applica HAIMER 100"}

INT C = INPUT CHOICE $Choices "6R1"
IF $C==0 {
MACRO "C:\main\6R1_sbalzo_50.mac"
} ELSEIF $C==1 {
MACRO "C:\main\APPLICA_PINZA_HAIMER.mac"
}

 

I have tons of macros, and all of them are inside long path folders.

 

I mean, to put all the macros into one mail folder "pmill6" I know there is a software that can move all the files nested from different folders  into one main folder at once.

 

But I need also to re write the path folders into each text contained into each macro. (impossible to change the path one by one by hand of each macro)!

 

 

 

all my macros are one word called, using _ as a separator, so it is a united word named_all_like_this_for_example.mac , maybe there is a way to thange the toolpaths folder into the text macro files?

some pyton editor?

or a powerfull text editor?

who knows?

 

If some had same problem and solved, please inform me.

No Idea on a reasonable solution

 

thanks a lot

 

greetings

Danny

0 Likes
1,196 Views
17 Replies
Replies (17)
Message 2 of 18

kevin.hammond3WX4X
Advocate
Advocate

If i am understanding you correctly you wish to edit a bunch a of macros and recognise and replace text within them?

If so might i suggest using Notepad++, a free download, i use it for this purpose from time to time.

kevinhammond3WX4X_0-1688383795318.png

 

Message 3 of 18

old_snickers
Advocate
Advocate

This will work, I use this occasionally too. But don't forget to make backup copies of your macro files before using this. The howling is much quieter when it went wrong  😉

0 Likes
Message 4 of 18

info
Contributor
Contributor

well I use notepad++ yet, but this way would mean to edit any single macro.

I have thousands.

I was thinking something that would recognize a generical pattern inside any text files, and into all of them change any different pattern whith my "main" unique patter, so all the macros I would put into that main singular folder.

I hoped the fact  that my macros are all named with a singular name spaced with _ , but a continuous_name.mac  could be helpfull.

I mean, in this example, MACRO "C:\pmill4\micromacro\MACRO_SGROSSATURA\VTR\6R1\6R1_sbalzo_50.mac", something similar to:

"in any text string path folder delete the path before the .mac name and sobstitute with C:\main\"

so it would like delete C:\pmill4\micromacro\MACRO_SGROSSATURA\VTR\6R1\ (all before "6R1_sbalzo_50.mac")

and sobstitute like this C:\main\6R1_sbalzo_50.mac

because I have a lot of simple macros. a lot.

sob

 

 

0 Likes
Message 5 of 18

old_snickers
Advocate
Advocate

This is exactly, what kevin.hammond3WX4X suggested. You have to use the "Find in Files"-tab to let Notepad++ find in each of the thousands files the string "C:\pmill4\micromacro\MACRO_SGROSSATURA\VTR\6R1\" and replace it with "C:\main\". Believe me, this will work! But there will be no backup, so be careful!

0 Likes
Message 6 of 18

kevin.hammond3WX4X
Advocate
Advocate

1st: make a backup of the entire area that you are going edit, just in case you get podgy fingers and mistype something.

 

In Notepad++ click 'Search', then 'Find in files'

Enter text to find and replacement text, and search path i.e C:\pmill4 or wherever your macros are stored.

Click find all, you will be informed how many you have found, if your are happy with search results you can then click replace all.

repeat search for each replacement as required.

 

kevinhammond3WX4X_0-1688537468240.png

 

0 Likes
Message 7 of 18

info
Contributor
Contributor

thanks for trying, but the matter is that each macro contains a different path folder (or more than one path).

that's my problem .

I need an application that recognize  and select the whole path inside the macro, whatever it is, selecting all the path before the_last_world.mac (with the_last_world.mac I mean the macro name)

my only advantage is that the macro names in the end are a single word.mac or a word_separated_by_underscores.mac for example.

0 Likes
Message 8 of 18

old_snickers
Advocate
Advocate

For my understanding: so you have thousands of macros containing hundreds of different paths and you would have to repeat the described procedure a hundred times?

You need something which can find in all of the files any line with MACRO " and replace "whatever" between MACRO " and the last backslash \ before the second quote with a new string (your actual macro-folder). That's the idea, but I don't know any application, where you can define according rules for this "whatever".

Message 9 of 18

old_snickers
Advocate
Advocate

I have not tested it, but eventually the "Replace Text" application (formerly known as "BK ReplaceEm") can do this in a way you need. There should be a function called "range search" where at least the start- and end-conditions for "find" can be defined.

0 Likes
Message 10 of 18

Y.Mahran
Contributor
Contributor

Hi @old_snickers , thanks for summarizing & troubleshooting the problem, here is a simple (.exe) file made by Python that does what you have described.

 

(view in My Videos)

 

@info, Kindly note that the program used will overwrite the macros files, so make sure that it is not being used/opened by another program and that you have a copy/backup just in case any thing goes wrong.

 

Hoping that your problem is solved.

0 Likes
Message 11 of 18

benettitec01
Enthusiast
Enthusiast

you are a genius. And thanks a lot! just one answer: how can I change the destination  path ? (instead of  C:\main\  can I insert in the program another path? how?

thanks a lot

I was info. Now I changed my account name.

thank you!!!!!!!!

Message 12 of 18

Y.Mahran
Contributor
Contributor

Hi @benettitec01,

 

I made a modification so that you can insert the macro path.

 

(view in My Videos)

 

 

Message 13 of 18

benettitec01
Enthusiast
Enthusiast

yeah you are!

(genius)

thank you!

 

now I discover that I have duplicated names, for example  I have a lot of 1.mac  (and some 1_1.mac yet) nested in different folders.

I wanted to serch and copy all my nested macros, all of them, into a unique main folder .

I'd need to rename all the duplicated names not manually (there are 20 1.mac, 3 1_1.mac , 3 1_2.mac and so on with 2.mac ) and I have 10_36 for a macro that rotate of 36 degrees for example.

 

is there another way than manually, for example adding suffix a b c d e.....?

anyway this  Macro path finder helps me a lot!!!!

 

 

thank you again!!!!

 

Danny

0 Likes
Message 14 of 18

Y.Mahran
Contributor
Contributor

Hi @benettitec01 ,

 

First of all, I am glad to hear that I could help you.

 

Second, I am sorry for taking so long to reply to your request, I was a bit busy.

 

The following python code does the following:

1) Searches for (.mac) files in the current working directory and in its sub-folders.
2) Sorts the macros by their names
3) Copy the macros from their source location to a choosen distenation
4) Renames the macros to prevent any duplicated names

 

 

I hope that I answered your question

(view in My Videos)

Message 15 of 18

benettitec01
Enthusiast
Enthusiast

Hi and thank you . 

I just ask you , last one and if and when you can . 

I have to cut away the part _VTR  in a lot of macro files names.

for example 

HAIMER_100_SU_4R2_VTR.mac

should become 

HAIMER_100_SU_4R2.mac

Is it possible?

Or, since you are a master on this, if possible to input the part to be changed or deleted.

I mean to choose if _VTR or _ZEPHYR or input part to be cut off or sobstitute.

this Is my last ask and I really thank you because otherwise it was impossible for me to come out of the trouble

Thank you again really.

And have good holidays If you can

 

Danny

0 Likes
Message 16 of 18

Y.Mahran
Contributor
Contributor

Hi @benettitec01 

 

This tool will help you to change/delete the suffix of the macro files you have. note that the macro files should have at least one separator ( _ ).

 

(view in My Videos)

 

By the way, thanks for your kind words. But, I am not a genius or a master in Python, it is just simple code lines. 😊

Message 17 of 18

benettitec01
Enthusiast
Enthusiast

AND THANKS AGAIN 2 TIMES!!!!

and have good holidays and rest of summer!!

Danny

 

0 Likes
Message 18 of 18

benettitec01
Enthusiast
Enthusiast

Since I have a lot of omonimous files nested and nested,

I thought that the only way to definitely solve should to rename the files like the follow example:

I have , for example two files named 1.mac nested like that:

"C:\pmill2\pmill2nascoste\SPIGOLO FORM TOOLPATH\VTR\1.mac"

"C:\pmill2\pmill2nascoste\SPIGOLO FORM TOOLPATH\1.mac"

I'd need to rename the file with the FIRST letter of  each nested folder NAME like this:

ppSV1.mac

ppS1.mac

(or better       ppSV_1.mac      ppS_1.mac)

 

I this also possible?

I am ashamed to not have yet solved and ask again help but this may be the very last request

 

Thanks anycase 

Danny

 

 

0 Likes