Sign in to follow this  
Followers 0
KenRainsforth

Using variables in MoveDir

3 posts in this topic

Hi everybody

Help

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")

Exit

Else

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

EndIf

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.

Ken

Share this post


Link to post
Share on other sites



don't need to put Double quotes in the string... :)

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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.

Example:

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  
Followers 0