Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update multiple prg files at the same time? 1

Status
Not open for further replies.

DB Boxers

Programmer
Jan 3, 2022
3
US
Hi, pardon the newbie question. Would like to update multiple prg files in a folder at the same time, without having to open each file. Goal is to change the directory location from \\origserver\Reports\ to \\newserver\Reports\ across all the files. Is that possible?

Thank you.
 
Most programmers' editors will allow you to do this. I use Notepad++, but there are several others. All you have to do is to go to Search > Find In Files (or equivalent), then specify the text that you want to find, the replacement text, and the folder that contains the files. That way, all the changes will be made in one go, with just a few clicks.

Welcome to the forum, by the way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Others understand your problem as multiple file search & replace. Well, that's easy.
But is it really the problem?

I don't mean to understand it differently than a global search&replace, but there are also ways to set up a server alias in windows, so the new server is seen by the old name, so that could be solved by an (network) admin too. See netdom command.

Chriss
 
Mike Lewis said:
Most programmers' editors will allow you to do this. I use Notepad++, but there are several others.

I use NOTEPAD++ for editing Arduino Files (single-board microcontrollers) and editing XML files, but have never considered using it for VFP. Is there a 'User Defined Language' available for VFP?


Regards,

David (G4NVB)

Recreational Developer / End User of VFP.
 
David,

I wasn't suggesting that he use Notepad++ for editing VfP files, but rather for the limited requirement of doing a bulk replace for a directory location. Doing that is in no way specific to VFP.

As far as I know, nobody has ever created a user-defined language for VFP in Notepad++. If one existed, I'm not sure if I would use it, given the conveninece of editing in the VFP IDE. But I'm not sure.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I don't know one, David, and I fear it won't help much anyway.

But aside of that you can still use notepad for replacement in any text files of a whole directory without it knowing anything about the language.

Chriss
 
Thanks all, I appreciate the responses. I have over 100 Foxpro prg files and was looking for an update option that didn't require having to open every file.

Cheers!
 
When you're using search&replace, think about a solution that would just SET DEFAULT TO the report directory or add it to SET PATH, then remove the base path prefix instead of replacing it with a new path.
The netdom solution still should be applicable without any code changes.

Chriss
 
I have over 100 Foxpro prg files and was looking for an update option that didn't require having to open every file.

My suggestion would have met that requirement. You would only have had to open the editor. Everything else would have been done behind the scenes.

And Chris's suggestion might be even simpler.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike Lewis said:
As far as I know, nobody has ever created a user-defined language for VFP in Notepad++.

All understood. I much prefer using NOTEPAD++ rather than the Arduino IDE although I am happy to continue using the VFP IDE and GoFish5 but thought I'd ask just in case a VFP UDF Language did exist.



Regards,

David (G4NVB)

Recreational Developer / End User of VFP.
 
Got it, thanks again. As I wasn't able to get NotePad++ option to work, not familiar with that program. I kept searching and found a Powershell script that quickly modifies the content. Here 'tis if it's of any use to others.

Get-ChildItem "C:\FOLDER" -Recurse | ForEach-Object -Process {
(Get-Content $_) -Replace 'origserver', 'new server' | Set-Content $_
}
 
Just to mention it:

Notepad++ menu: Search: find in files. Allows finding in files of a directory, not only in open files. So as others said, you only start notepad, then not open any files, just go straight to the search dialog.

Hotkey CTRL+SHIFT+F

Besides GoFish and VFPs native Code references can also do that, including to process all files of a directory.

You know I'm not in favor of this as it doesn't really solve the underlying problem of hardcoding paths, but let's keep it at that. Powershell just like notepad++ are useful in more than this case, that's for sure. To many, Powershell is limited by group policy, whereas you can use Notepad++ also without install as portable app.

Chriss
 
VFP's Code References is there to do that... search for the string, select all the files and replace with the new string...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Griff, you are right about Code References (Chris also mentioned it as a possibility). Personally, I would prefer Notepad++ for this job, as the whole process is quite a bit simpler. Then again, I already have Notepad++ installed. It wouldn't be worth installing it just for this one job.

One advantage of Code References is that it lets you manually review and de-select any files that you want to omit from the replacement process - although that would be an onerous task in this case, given the number of files involved.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
ggreen61 said:
Attached is a NotePad++ definition file for VFP that I use.

Thank you Greg, I will download the file and have a play.

Regards,

David (G4NVB)

Recreational Developer / End User of VFP.
 
Great. It's differing a bit from the one I find in
It still doesn't go as far as defining intellisense information and syntax coloring only applies to full keywords, for example, not the usually 4 letter abbreviations (except LOCAL/LOCAT).

You could now add a line to config.fpw (adjusted to your installation:
Code:
TEDIT=/N "C:\Program Files\Notepad++\notepad++.exe"

And that VFP feature of TEDIT only applies to PRGS and txt files, you can't override the internal editor when editing a visual class (of a vcx class library).

Chriss
 
Greg, thanks for posting that. Did you create that file yourself? Well done if so. It must have been a lot of work. But I doubt if I would use it myself for day-to-day editing, although it could be useful in some circumstances.

The obvious benefit is that it would enable you to use all of Notepadd++'s powerful features when reviewing a PRG, but its version of Intellisense appears to fall short of VFP's in some respects. I hate to criticise, especially as this is something that I would not be capable of creating myself. At least, it's good to know that this is possible.

I haven't looked at the one on GitHub that Chris mentioned. I'll do that soon.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

indeed, I agree with the ambiguity. It would really be nice to have a new editor capable of more features, but then several things about the internal editor are just better. For example opening a file you edit exclusive, as hard as that could also be a problem sometimes and as little as it plays a role if you program alone, a feature like compile before saving and the indication the current line can compile or not, that's some feature you can't do with an external editor, unless it's also a VFP compiler.

Hints on the possibility of doing such an editor with VFP itself, of course.

Some of the pro features of notepad are collapsing nested code. And while that feature is nice, you'll surely miss the VFP document view to easily jump to certain points in the code, which I personally find working better than collapsing and expanding.

These features are never gonna be done within notepad++ no matter how you can extend the user defined language definition.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top