Sign in to follow this  
Followers 0
Guest MBMatt11

FileMove Help Needed - Urgent!

7 posts in this topic

I cannot seem to get filemove to work.

Here is my script:

DirCreate("C:\dfgjflk")

FileMove (@StartupDir &"\NVSTRD.lnk","C:\dfgjflk\*.*")

however this works:

DirCreate("C:\dfgjflk")

FileCopy (@StartupDir &"\NVSTRD.lnk","C:\dfgjflk\*.*")

How come FileCopy works but not FileMove, I cannot figure this out!

Thank you

Share this post


Link to post
Share on other sites



Actually it seems like this is a bug.

Wildcards are not supported in FileMove in my version at least. (although it says they are)

This works:

DirCreate("C:\dfgjflk")
FileMove ("c:\NVSTRD.lnk","C:\dfgjflk\NVSTRD.lnk")

This doesn't:

DirCreate("C:\dfgjflk")
FileMove ("c:\*.lnk","C:\dfgjflk\*.*")

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

That's not a bug, that's incorrect syntax. Neither *nix mv nor MS-DOS move commands accept that syntax, either. To move a file to a directory, you use FileMove("C:\The\file.txt", "C:\New\directory\"). This would put "file.txt" in "C:\New\directory\". To use a wildcard, it would be FileMove("C:\all\*.txt", "C:\new\directory\"). This would move all "*.txt" files into "C:\new\directory\".

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Valik, try your code and tell me not a bug again.

To use a wildcard, it would be FileMove("C:\all\*.txt", "C:\new\directory\"). This would move all "*.txt" files into "C:\new\directory\".

FileMove("C:\all\*.txt", "C:\new\directory\")

...edit, oh I also agree that it isn't correct syntax, I was posting the closest example from the help file.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

This doesn't even work either:

FileMove("C:\path\to\file.txt", "C:\new\path\")

It seems you have to specify both the source and destination paths INCLUDING filename. I thought I had used FileMove in the past like I do on Linux/DOS where I just specify the new path and it moves the file preserving the name. Apparently I dreamed that or something however. Thanks for correcting me on that.

Share this post


Link to post
Share on other sites

If you need to move a bunch of files, you might use a function like this:

$path="C:\all\"
$files="*.txt"
$desination="C:\new\directory\"

FileMover($path,$files,$desination)

Func FileMover($path,$files,$dest)
    $err=1
    $move=FileFindFirstFile ($path & $files) 
    While $err=1
  $err=FileMove ($path & $move,$dest & $move)
    $move=FileFindNextFile () 
Wend
EndFunc

It finds each file and uses the filemove().

Or you can use the DOS commands.


AutoIt3, the MACGYVER Pocket Knife for computers.

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