Jump to content

How To Delete Files From Gsak Macro?


Recommended Posts

Posted

I have a macro to create MS S&T files by cache type. At the beginning of it, I want to delete all of the existing files in the given directory, so that if on a given occasion there are no new files created for a given type, I won't pick up an old one.

 

I assume I have to use a RUNPGM command, but I haven't figured out just how to get it to do what I want.

 

From a DOS prompt, I would enter: DEL C:\Data\GSAK\Home\SNT\*.csv

 

The GSAK macro equivalent would be . . . . ??? B)

Posted (edited)
I have a macro to create MS S&T files by cache type. At the beginning of it, I want to delete all of the existing files in the given directory, so that if on a given occasion there are no new files created for a given type, I won't pick up an old one.

 

I assume I have to use a RUNPGM command, but I haven't figured out just how to get it to do what I want.

 

From a DOS prompt, I would enter: DEL C:\Data\GSAK\Home\SNT\*.csv

 

The GSAK macro equivalent would be . . . . ???  B)

You could create a Batch file in your GSAK\Macros\ folder (use a plain text editor, the same one you use to create GSAK macros will do fine) with this command

 DEL C:\Data\GSAK\Home\SNT\*.csv

and call it something like DeleteCSV.bat.

 

Then create a GSAK Macro that includes this line

RUNPGM pgm="C:\Program Files\GSAK\Macros\DeleteCSV.bat" wait=YES

 

Edited to correct typo!

Edited by Motley Crew
Posted
I have a macro to create MS S&T files by cache type. At the beginning of it, I want to delete all of the existing files in the given directory, so that if on a given occasion there are no new files created for a given type, I won't pick up an old one.

 

I assume I have to use a RUNPGM command, but I haven't figured out just how to get it to do what I want.

 

From a DOS prompt, I would enter: DEL C:\Data\GSAK\Home\SNT\*.csv

 

The GSAK macro equivalent would be . . . . ???  B)

You could create a Batch file in your GSAK\Macros\ folder (use a plain text editor, the same one you use to create GSAK macros will do fine) with this command

 DEL C:\Data\GSAK\Home\SNT\*.csv

and call it something like DeleteCSV.bat.

 

Then create a GSAK Macro that includes this line

RUNPGM pgm="C:\Program Files\GSAK\Macros\DeleteCSV.bat" wait=YES

 

Edited to correct typo!

Whoa. :blink:

 

Too simple. :lol:

 

Thanks for the suggestion! :(

Posted

It's actually easier than that. Assuming you're using anything Windows 2000 or newer:

RUNPGM Pgm="C:\Windows\System32\cmd.exe" Parms="/C del /Q C:\Data\GSAK\Home\SNT\*.csv" Wait=Yes

You run the windows command interpreter with the del command as an argument. The \Q argument to del is so that it won't ask you for confirmation when deleting multiple files.

Posted
It's actually easier than that.  Assuming you're using anything Windows 2000 or newer:

RUNPGM Pgm="C:\Windows\System32\cmd.exe" Parms="/C del /Q C:\Data\GSAK\Home\SNT\*.csv" Wait=Yes

You run the windows command interpreter with the del command as an argument.  The \Q argument to del is so that it won't ask you for confirmation when deleting multiple files.

For windows 2000 you'll need to use WINNT in place of Windows

RUNPGM Pgm="C:\WINNT\System32\cmd.exe" Parms="/C del /Q C:\Data\GSAK\Home\SNT\*.csv" Wait=Yes

Posted

Holy Crap ;) I thought I was a computer geek, but this stuff just flew over my head. Something tells me I am getting too old...

 

This does sound very usefull though. Just to confirm, this code would export a .csv file of all the chosen caches and save it to the directory of choice, in this case SNT, but first it will delete any and all files within that directory?

 

Could this be done to creat a regular old .GPX file as well? Given the fact that the .csv could be replaced with .gpx?

Posted
Holy Crap ;) I thought I was a computer geek, but this stuff just flew over my head. Something tells me I am getting too old...

 

This does sound very usefull though. Just to confirm, this code would export a .csv file of all the chosen caches and save it to the directory of choice, in this case SNT, but first it will delete any and all files within that directory?

 

Could this be done to creat a regular old .GPX file as well? Given the fact that the .csv could be replaced with .gpx?

Yep, you can do this and a whole lot more with the macro language.

 

Please see the "Automating GSAK" topic in the help file or online here http://gsak.net/help/hs21000.htm

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...