Global Mapper v25.0

RUN_COMMAND replace apostrophes

MKaran
edited February 2017 in GM Script Language
Hello!

I am working on a custom .gms file that needs to COPY tfw files from one location to another. Some CMD functions have syntax that need apostrophes preserved, not replaced with quotation marks. From the scripting guide:  If you need to use quotation marks in your command line, instead use apostrophes (i.e. ' rather than ") and they will be converted to quotes prior to running the command. 

I would like the option to preserve the apostrophe syntax in my command. For instance: 

RUN_COMMAND COMMAND_LINE="cmd /C for /F %f in ('dir /b C:\Users\Desktop\old') DO COPY 'C:\Users\Desktop\old\%f' 'C:\Users\Desktop\new\%f'" WAIT_FOR_COMPLETE=YES

Answers

  • bmg_bob
    bmg_bob Global Mapper Programmer
    Hello,

    Have you tried putting your command into a batch file (.bat)?  Then you can just run the batch file.  Something like this:
    RUN_COMMAND COMMAND_LINE="'c:\temp\copy_files.bat'" WAIT_FOR_COMPLETE=YES
    Cheers,
    Bob

  • MKaran
    edited February 2017 Answer ✓
    I am looking to make a "one stop shop" script to be use by my team who are not familiar with global mapper or cmd: Copying the GMS into their parent source directory, double click, and having the executable run. I do see the ".bat file" as a solution, but it would require a unique bat file for each set that cannot use the variables set up in my .gms (requires an extra step)

    The paths used are set up with DEFINE_VAR, depending on where the .gms file is located

    Any alternative suggestions? Maybe a more clever cmd command to COPY files that doesn't use '..' ?
    Can global mapper create temp .bat files?

    Thanks!
  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited February 2017 Answer ✓
    Hello,
    MKaran said:

    The paths used are set up with DEFINE_VAR, depending on where the .gms file is located

    Any alternative suggestions? Maybe a more clever cmd command to COPY files that doesn't use '..' ?
    Can global mapper create temp .bat files?

    You can specify arguments when calling a batch file, which you could use to pass values that you set up using DEFINE_VAR into the batch file.
    RUN_COMMAND COMMAND_LINE="'c:\temp\copy_files.bat' %VAR1%  %VAR2%" WAIT_FOR_COMPLETE=YES
    I have opened an item (#20858) in our task list to add a new parameter to RUN_COMMAND that will preserve apostrophes in the command line.  We will post a message on this thread when the status of the request changes.

    Cheers,
    Bob