Need a solution (Find files and replace text inside)

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Need a solution (Find files and replace text inside)

Post by *dragonworks »

Don't know if TC can do what I propose but you guys have helped me in the past and I have been pleasantly surprised so, here we go, and once again I am not sure of the phrasing of the questions?
I have a network drive F:\
On that drive I have the following path: F\CNC PROGRAMS \MILL\MILLPROGRAMS\
Inside the MILLPROGRAM DIRECTORY ARE A SERIES OF DIRECTORIES NAMED 111, 121, 131, ETC.
Inside those directories are a series of directories named by part number such as 111-00-00-0001 etc.
Inside those directories are individual folders for my Mastercam programs, set up sheets , machine programs etc.

So the path may be as follows F:\CNC PROGRAMS\MILL\MILLRPOGRAMS\111\111-00-00-0001\POST\

In that particular folder directory is a file named 111-00-00-0001 OP1.NC
there may be one or more of the these .NC files in the Post directory (they are just text files and can be read with just about any text editor)
each of these files will contain one of the following codes, G54, G55, G56, G57. G58, G59
I have to go into each one of these files, and there are thousands of them, and anyone that contains any of the codes besides G54, that code needs to be
changed to G54.
So, if the file contains G55, G56, G57, G58, or G59, that line of code needs to be changed to G54.

Is there anyway I can use TC to help me accomplish this in a more timely manner?
Thanx
Jerry.
User avatar
Gral
Power Member
Power Member
Posts: 1609
Joined: 2005-01-26, 15:12 UTC

Re: Need a solution.

Post by *Gral »

You can use text editor e.g. Notepad++.
First use TC to find all these files, e.g.:
Commands - Search:
Type
Search for: *.NC
Search in: F:\CNC PROGRAMS\MILL\MILLRPOGRAMS\111\111-00-00-0001\POST\
Find text: G5[56789]
RegEx(2): check
Find all files, feed to listbox, select all send to Notepad++ (e.g. you can create button for Notepad++ with %P%S parameter first)
After load all files in N++, go to Search - Replace
type:
Find what: G5[56789]
Replace with: G54
Tick "Regular expresion"
Press "Replace All in All Opened Documents"
Go to Window - Window - select all with CTRL+A, press "Save"
dragonworks
Junior Member
Junior Member
Posts: 29
Joined: 2015-10-20, 20:00 UTC
Location: poughkeepsie ny

Re: Need a solution.

Post by *dragonworks »

I started with one directory, got as far as where you state to feed to listbox. I can't find any command for that, so did not get any farther but it is working up to that point. I was able to seperate all the files in that director that didn't have the G54 in them with no problem. I will keep working on it.
Thanx
User avatar
Gral
Power Member
Power Member
Posts: 1609
Joined: 2005-01-26, 15:12 UTC

Re: Need a solution.

Post by *Gral »

There is "Feed to listbox" button on "Find files" RESULTS window.
Post Reply