Deleting local file using dispatch

Hello,

My process require me to convert a drawing to PDF and save it outside the vault with the new version.  Ex: PartA_R1.pdf

When we re-approve this file, the Convert Task will create a new PDF outside the vault and name it PartA_R2.pdf

We do not want to leave PartA_R1.pdf in the directory...  we only want to keep the latest version in the folder.

In the vault, the latest file name would be for exemple, PartA.SLDDWR and by using the Dispatch tool, I am able to display the full name of the file on the local drive using a combination of strings and arithmetics functions stored in the %CurrentPDFVersion% variable with the OK MessageBox. 

EX: The file %CurrentPDFVersion% will be deleted  => will display The file PartA_R2.pdf will be deleted

Why does the Delete File Function with the argument filename:  c:\\test\\%CurrentPDFVersion% does not work???

the file PartA_R2.pdf is stored in c:\\test\\

and I try to change the argument of the Delete File Function to  c:\\test\\PartA_R2.pdf, then it Does work!  so I assume I am not far away from an answer...

please help!

Thank you,

Eric

SolidworksSolidworks Pdm enterprise Pdm
Answers 2
SF
SF 2013-11-25 Best Answer

Eric,

Haven't run into this before, but try setting the %CurrentPDFVersion% variable to c:\test\PartA_R2.pdf and use only that in the delete dialog and see if that works for you.

BM
BM 2014-02-06

I'm testing something similar.  I noticed there is a delay -  I've seen it take a couple minutes for the file to disappear.

Below image shows the 3 variables I used, since nesting functions didn't seem to work.  I used this to change extension to .pdf. 

I also put in a message box that shows me the name of d_deletename so I know what it is trying to do, sounds like you have that already...

The problem I'm actually having is I need a wild card.  I can't get it to work when there is an unknown date (inserted by pdf task) at the end of the filename (eg 42019 - Frame Holder Gear-02_06_2014.pdf). 

comment imagecomment image