Jump to content
Sign in to follow this  

Using variables in MoveDir

Recommended Posts

Hi everybody


I'm new to AutoIt and I have a little problem.

Im editing and running the program from the SciTE editor.

I want to rename a directory, my script is ...

$olddir = Chr(34) & IniRead($inifile, "Migrate", "Root_Dir", "NotFound") & Chr(34)

$newdir = "D:\Demos\NXT Test\Test Library\Temp"

;Folder rename Migrated to Temp (This was the last built folder)

;Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!

MsgBox(4096,"",$olddir & "Directory will be renamed " & $newdir)

DirMove($olddir, $newdir, 1)

If @error Then

MsgBox(4096,"Could not rename directory","Press OK to quit program")



MsgBox(4096,"","Renamed " & $olddir)


If I use literal filepaths like this .....

DirMove("D:\Demos\NXT Test\Test Library\Migrated", "D:\Demos\NXT Test\Test Library\Temp")

it works

Also I dont get at an error from the first example.

I'm using the latest release of AutoIt.

What am I doing wrong?

Any help would be appreciated.


Share this post

Link to post
Share on other sites

What am I doing wrong?

To add to what JdeB suggests, you only need to quote the paths in the functions to run files reliably that contain spaces.


Run('"quote paths with spaces"')
RunWait('"quote paths with spaces"')
ShellExecute('"quote paths with spaces"')

Run(@ComSpec & ' /c "quote paths with spaces"')

Other functions do not like quotes so they may fail through trying.


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...