Skip to content
PD
Browser Automation Studio

Working with Paths in BAS

The Path module in Browser Automation Studio — build, normalise and resolve file and folder paths dynamically so a bot finds its files wherever it runs.

A bot that hardcodes C:\Users\me\bot\data.txt breaks the moment it runs on another machine. The Path module is how you avoid that — building paths dynamically so files resolve correctly wherever the script lives.

Why paths need their own module

A dynamic path is a path to a file or folder that changes depending on its location. You rarely want a fixed absolute path; you want “the data file next to this script” or “the profiles folder inside the project.” Two common cases the module solves: placing browser profiles in the project’s root folder as the bot runs, and figuring out a file’s extension from a path you received.

The actions

Resolving project locations.

  • Path to project directory — the folder the project lives in.
  • Path to project file — the project file itself.
  • Get system path — a known system location.

Build everything relative to these and the bot stays portable.

Constructing and cleaning paths.

  • Combine path — join a directory and a name into one valid path, without worrying about slashes.
  • Normalise path — clean a path into a canonical form.
  • Set path — set the working path.

Inspecting a path.

  • Get the file from a path — pull the filename out.
  • Get the path from a path — pull the directory out.
  • Get file extension — read the extension, e.g. to decide how to process a downloaded file.
  • Is the path absolute — check whether a path is absolute or relative before using it.

The habit

Treat hardcoded absolute paths as a bug. Anchor on the project directory, combine to reach your files, and normalise what you build. Do that and the same bot runs unchanged on your machine, a teammate’s, and the VPS you deploy to — which is exactly what you want once a project leaves your desk.

FAQ

What is a dynamic path in BAS?

A dynamic path is a path to a file or folder that changes depending on where the script runs. Instead of hardcoding a location, you build the path relative to the project so the bot finds its files on any machine.

How do I reference the project folder in BAS?

The Path module provides actions for the path to the project directory and the project file, plus combine and normalise. Build paths from the project directory so profiles, resources and outputs resolve correctly wherever the bot is run.

More on this topic

  • #Browser Automation Studio
  • #BAS
  • #Paths
  • #Files
  • #Portability

Have an idea? Let’s turn it into a working product.

Skip months of uncertainty. Get a clear architecture, a working MVP and a system you can test, sell and scale.