cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to loop through MathCad files?

Highlighted
Newbie

Script to loop through MathCad files?

Hi,

At our division at work we use Mathcad-15 for writing our technical reports and saving them to PDF. Then we print the PDFs to store in a physical archive.

For archiving purposes every report contains the file path to allow someone to find the digital version of the report even on a printed copy.

It looks something like this:

"The digital copy of this report can be found here:"

\\disk1\folder\subfolder\report.xmcd

We are now moving our digital copies to a new disk, let's call it "disk2".

Hence, we need to change the files paths in all the reports to:

\\disk2\folder\subfolder\report.xmcd

We also need to save all reports to PDF, after the file path has been updated.

Since we have some 500 reports to update my question is if this is scriptable? Both changing the file path and saving as PDF.

If so, can someone support us on how to do it?

Best regards,

Oskar

Tags (2)
5 REPLIES 5

Re: Script to loop through MathCad files?

While I think it can be done, I would recommend for environmental considerations that:

1. You would place a single sheet of paper in the archive that says that

"files that formerly were to be found on \\Disk1\folder\... are now to be found on \\Disk2\folder\...".

and/or,

2. You create a link on \\Disk1\folder to point \\Disk2\folder.

In addition, change the archiving procedure to omit naming the actual disk, and use as archive root a logic name e.g. "DepartmentArchive", the exact location of which you define in that procedure only.

Then such disk moves don't involve changing any documents at all.

Success!
Luc

Re: Script to loop through MathCad files?

What you want to do is possible. The Mathcad files with .xmcd extension are in XML, which is plain text. Finding the path and changing it shouldn't be too hard. Then you would need to call Mathcad via the automation interface, load the worksheet, and use the printall method to print it to pdf. Writing a script to do all of this, and testing it to make sure it's reliable (you can't check 500 worksheets by hand to make sure they didn't get corrupted in some way!), would be quite a lot of work though.

Re: Script to loop through MathCad files?

Don't worry. The reports have not been printed yet

We would probably go with your first suggestion otherwise.

The second suggestion is actually not a bad idea. Thanks for that!

Regarding the archiving procedure, it's unfortunately not that simple, but thanks for the tip!

Re: Script to loop through MathCad files?

I noticed the first thing, and I guess I would manage to script that.

The latter one though is out of my league, when it comes to scripting...

Re: Script to loop through MathCad files?

Open a command line window, and go to the Mathcad 15 program folder. Type mathcad.exe -p "path and name of file". It makes Mathcad open just long enough to send the file to the default printer . So if you make your pdf printer the default, you could create a batch file that would print all the Mathcad documents. The pdf printer I use (CutePDF) prompts for a filename every time, but maybe there are some that don't. It always offers a default name though, so worse case, you have to hit "OK" 500 times.

Announcements