Jump to content
Sign in to follow this  
Sam31

Search file and move

Recommended Posts

Sam31

I looking for a script which can do this:

----------------------------------------------

pathA = C:\folder01\

pathB = C:\folder02\

For all files in pathA

If file_name start with "B"

Then move to pathB

----------------------------------------------

Thanks

Share this post


Link to post
Share on other sites
Sam31

I find if stringleft function but my prob is the search function

Share this post


Link to post
Share on other sites
Sam31

Ok finally it's not necessary to do anything special: "Filemove" function that all I need.

Share this post


Link to post
Share on other sites
Mikeman27294

Ok, well I am not aware of a FileMove() function native to AutoIT, so this is what I do:

Func _FileMove($Source, $Destination)
    FileWrite($Destination, FileRead($Source))
    FileDelete($Source)
    Return
EndFunc

And if you want to copy the file rather than move it, it is a similar function, but without the delete.

Func _FileCopy($Source, $Destination)
    FileWrite($Destination, FileRead($Source))
EndFunc

Hope that helps.

Share this post


Link to post
Share on other sites
hannes08

Ok, well I am not aware of a FileMove() function native to AutoIT, so this is what I do:

Func _FileMove($Source, $Destination)
    FileWrite($Destination, FileRead($Source))
    FileDelete($Source)
    Return
EndFunc

Well, you're aware that this is very - veeery inefficient - right? Better use FileMove() because it doesn't write a complete file but instead just moves entries in the filesystem.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites
Mikeman27294

Oh, so there is actually a command for that? Didn't come up in my scite calltips. I better check that out.

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  

×