Jump to content
Sign in to follow this  

Help with reading path and stringreplace

Recommended Posts


#Include <File.au3>
#Include <Array.au3>

$Path = @ScriptDir
$Folders=_FileListToArray($Path, '*', 2)

$company = InputBox("Robocopy Maker", "Company Name?", "", " M")
$drive_pre = InputBox("Robocopy Maker", "Destination Drive Letter?", "", " M1")
$destinationdrive = StringUpper($drive_pre)
$File = $company & ".bat"

; Remove drive letter from Path
$workingpath = StringTrimLeft($Path, 1)
; Combine to form new destination directory
$destinationpath = $destinationdrive & $workingpath

; Error checking
If @Error=1 Then
    MsgBox (0,"Error","No Files\Folders Found.")

; Trim folder count from array
$count = "0"
_ArrayDelete($Folders, $count)

; Pre and Post commands
$pre = "start robocopy "
$post = " /E /DCOPY:T"
For $i = 0 to UBound($Folders) -1
    $Folders[$i] = $pre & '"' & $Path & "\" & $Folders[$i] & '" "' & $destinationpath & "\" & $Folders[$i] & '"' & $post

_FileWriteFromArray($File, $Folders)

; Display results
Run("notepad.exe " & $File)

I am wanting to read the $workingpath as a string and if the path contains a "%" character anywhere in the path, then I want to do a stringreplace and change the single % into a double %% (weird robocopy issue that needs two %'s to actually pass a % as a character and not a variable)

I am wondering how I can read and modify the string while it is working inside the arrays. I don't really understand arrays too well.

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.