Jump to content

Recommended Posts

Posted (edited)

Im trying to write a script which will create x amount of folders with a given name using an array or similar.

But im having trouble getting the folders to be created exactly where i want them to be using an array.

My example code is:

#include <Array.au3>

$text = "Clients\"
$user = "Paul\Chris\Frank\"
$array = StringSplit($user, '\', 1)

Dircreate("C:\Documents and Settings\Administrator\desktop\" & $text & $user)

I understand the way i have written is its not correct for my purpose but i am unable to work out how i rewrite it so it is.

Ill explain what i want to do.

I want to first create a folder called Clients, then create multiple subfolders called Paul, Chris and Frank.

The problem i have is, each sub folder is being created inside the previous, rather than all being created in the Clients folder.

Example: Result is Clients\Paul\Chris\Frank

But i want

Clients\Paul

Clients\Chris

Clients\Frank.

How can i modify the code to achieve this? Thanks for any help you can give.

Edited by SXGuy
Posted

$text = "Clients\"
$user = "Paul\Chris\Frank"
$array = StringSplit($user, '\', 2)

For $i = 0 To UBound($array) - 1
    DirCreate(@DesktopDir & '\' & $text & '\' & $array[$i])
Next

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

Thank you!

I knew it would be something along those lines, but just wasnt sure.

This has really helped, thanks again.

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
  • Recently Browsing   0 members

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