1

I'd like to write a bat file that can open a folder based on a string.

For instance if the job code is A100

I'd like it to open X:\A Contracts\A100

for B200

X:\B Contracts\B200

etc.

i.e. A etc. is the contract and needs to be one string to allow the "A Contracts" part of the path to be targetted and then the job code needs to be the end.

I have codes from A-D but the last part of the code is always the end folder. However, it is usually A100 - job name (which aren't easy enough to remember). Is it possible to target a partial match using this?

I'm used to writing in Matlab and other scripting languages but I'm a bit fresh with BAT files so any help is much appreciated.

Also, if it'd be possible for the script to keep CMD open and loop back to re-input the next code that'd be amazing!

Bennp2000
  • 11
  • 2

1 Answers1

1

This is a simple batch file witch will take user input and appropriately open windows explorer with your specifications.

@echo off
set /p code="Job Code: "
set dir="X:\%code:~0,1% Contracts\%code%\"
:: Open Explorer using %dir%
explorer %dir%

And that will do what you want. It shouldn't be too difficult to modify.

Mona

Monacraft
  • 6,510
  • 2
  • 17
  • 29