GeoTalks 2025 User Conference

Failing to create folders on the server

veddycent
veddycent Global Mapper User
Hi all,

I have a script which writes out some files and creates some folders if they don't exist, standard GM functionality.
However it works great when saving locally but when saving on the server it fails to create the folders.

Here is an example directory its fails on:
\\SERVER\Data\Store\Projects\_GM Script Testing\Data\Terrain\HP50SW\OS\HP50SW - OS.png

Everything in bold does not exist and GM is failing to create the folders/file. It does work if the folders exist but this not an option as there are hundreds of unique folders to create.

Here is the full script
=============================================================================
//Prompt user where to save all the files (pasting the directory is easier than navigation to a folder)
DEFINE_VAR NAME="PROJECT_LOCATION" VALUE="" PROMPT=YES PROMPT_TEXT="Paste project data folder directory: "

//Loops through a group with SHP files to crop the export too
LAYER_LOOP_START FILENAME="SHP<sub>*.shp"

//Gets the tile ID so we can use for the new folder name
DEFINE_VAR NAME="TERRAIN_TILE" VALUE="%LAYER_FNAME_WO_EXT%" REPLACE_STR=" - Terrain="

//Cleans up the SHP filename so we can use it for the exported PNG filename
DEFINE_VAR NAME="SAVE_IMAGE_NAME" VALUE="%LAYER_FNAME_WO_EXT%" REPLACE_STR="Terrain=OS"

//Combining all the variables to create the new file directory and filename
DEFINE_VAR NAME="SAVE_IMAGE_DIR" VALUE="%PROJECT_LOCATION%\Terrain\%TERRAIN_TILE%\OS\%SAVE_IMAGE_NAME%.png"

//Export the PNG
EXPORT_RASTER FILENAME="%SAVE_IMAGE_DIR%" TYPE="PNG" POLYGON_CROP_FILE="%LAYER_FNAME_W_DIR%" OVERWRITE_EXISTING="NO" SPATIAL_RES_METERS="2,2" GEN_WORLD_FILE="YES" GEN_PRJ_FILE="YES" BG_TRANSPARENT="NO"

LAYER_LOOP_END
=============================================================================


GM Version 19.1 and 20.1

Any help would be much appreciated!
Thanks
Tagged:

Answers

  • veddycent
    veddycent Global Mapper User
    I should include the errors I get:

    WARNING: Unable to generate RGB PNG file \\SERVER\Data\Store\Projects\_GM Script Testing\Data\Terrain\HP50NW\OS\HP50NW - OS.png
    Unable to create file \\SERVER\Data\Store\Projects\_GM Script Testing\Data\Terrain\HP50NW\OS\HP50NW - OS.png
    pngoverlay.cpp - 643
    Version: v20.1.0 (69) (64-bit)
    Build Time: Feb 25 2019 15:30:00
    Thread: Main UI Thread
    Last Op: File: f:\development_20.1\globalmapper\mapcatalogoverlay.cpp : 1791
    Windows 10 Pro (64-bit) Memory: 27,107,831,808 of 34,305,908,736 available, GDI Usage: 373 GDI (Peak 504), 158 User (Peak 273)

  • Mykle
    Mykle Global Mapper User Trusted User
    Spaces in file or pathnames are usually a problem requiring special handling.  Can you remove them?

  • veddycent
    veddycent Global Mapper User
    Unfortunately not. I don't think its spaces as Global Mapper (GM) exports if the directory exists.

    As a work around I create a txt file from GM with a list of all the desired directories then run it through a Powershell script to create them. Then export the data from GM which works just fine.

    Its a pretty quick extra step so not an issue.

    Hopefully the devs see this and fix it as its common functionality.
  • bmg_bob
    bmg_bob Global Mapper Programmer
    Hello,

    I ran a quick test in the Global Mapper 22.1 beta, and ran into the same problem you are having. I opened issue GM-11936 to resolve this problem. 

    As a workaround, I found that if I mapped a drive letter to the existing folder on the server, and used the drive letter in the script, Global Mapper created the folders successfully.

    Cheers,
    Bob
  • bmg_bob
    bmg_bob Global Mapper Programmer
    Answer ✓
    Hello,

    The fix for GM-11936 will be in Global Mapper 22.1, though it is not in the current beta.

    Cheers,
    Bob