Jump to content

Exploring Folders


Guest yeahns
 Share

Recommended Posts

Guest yeahns

Hi!

I'm having trouble with a piece of code where I want the user to name a folder and pick a place to put the folder. It looks like this:

$var2 = InputBox("", "Folder name", "", "", 200, 125)
$var1 = FileSelectFolder("", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0)
MsgBox(4096,"", $var1 & "\" & $var2)
DirCreate($var1 & "\" & $var2)
Run("Explorer.exe " & $var1 & "\" & $var2)
Exit

It works fine as long as you put the folder the user named in a sub-folder on the drive, like D:\subfolder, but when the user puts the folder directly on D:\ then I get D:\\ and the "Run("Explorer.exe " & $var1 & "\" & $var2)" does not open the recently created folder.

I'm probably doing a silly mistake but what would be the best way to solve this since I don't know if the user is gonna to put in a subfolder or directly on a drive?

Greatful for any help :)

Kind regards

Jens

Link to comment
Share on other sites

  • Developers

jens,

you could test if the $var1 ends with a \ and then remove it... like this:

$var2 = InputBox("", "Folder name", "", "", 200, 125)
$var1 = FileSelectFolder("", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0)
if StringRight($var1,1) = "\" then $var1=StringTrimRight($var1,1)
MsgBox(4096,"", $var1 & "\" & $var2)
DirCreate($var1 & "\" & $var2)
Run("Explorer.exe " & $var1 & "\" & $var2)
Exit

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest yeahns

Excellent!

I was looking for parameters in the Run command that could handle the problem, but using trim takes care of it.

Tank you JdeB!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...