Jump to content

[Solved] Open Folder Directory that contains commas


Recommended Posts

Hi,

I'm trying to create a program where the user can input a material number into a GUI and the script will search out and find the respected material folder. I've been able to piece together the file mapping part so that the correct folder is stored within a variable. However I can not seem to get the Run function to work as the directory contains commas. Could I please get assistance with this?

Here is some test code I've experimented with

$filepath = "C:\Users\annoymousx\Documents\" ; Variable Works
;$filepath = "C:\Users\annoymousx\Documents\Test with Spaces\"; Works with folder spacing
$filepath = $filepath & "Test with Spaces\"; Works with using a prior directory history
$filepath = $filepath & "Folder with ()"; Works if brackets are used

;$filepath = $filepath & "\Folder with ," ;Does not Work if comma is used in file directory
$filepath = $filepath & "\Folder with " & ""","""; Works if triple brackets are used

Run("explorer.exe " & $filepath)

 

So I've learnt if you put triple quotations around a comma it will work correctly. The challenge is, in the actual script i'm not manually entering in text.

Example:

$filepath = $filepath & $Materialclass[$classnum] & "\"

 

Which is put into a loop, then at the end of the script I have the correct file path saved to the variable but it may contain many commas. 

How would I take this variable with the correct file path and open windows explore to it?

Say if the variable contained the value: C:\Users\anonymousx\Documents\This folder has a ,\comma, (comma, comma,)\And more , here

Thanks for any suggestions,

 

Edited by AnonymousX
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...