Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

Using VBS to move files out from one folder to another

what commands in vbs will move files out from one folder to another?
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Try the code below:
Set fso=CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\CrmXpress")
Set files = folder.Files
For Each File in files
      fso.MoveFile "C:\CrmXpress\*", "C:\OblakConsulting"
Next

Open in new window


The command is MoveFile but it does not overwrite file in destination. In that case, you would want to try CopyFile with a flag to overwrite files and then delete the original file using DeleteFile method.
Avatar of Bill Prew
Bill Prew

Use the filesystemobject, and the MoveFile() and MoveFolder() methods.

VBScript >> Objects >> FileSystemObject | DevGuru


»bp
Avatar of E=mc2

ASKER

Thanks you.  Will this overwrite any files in the destination folder?
MoveFile() does not overwrite existing files, it will throw an error if that is encountered.


»bp

The command is MoveFile but it does not overwrite file in destination. In that case, you would want to try CopyFile with a flag to overwrite files and then delete the original file using DeleteFile method.
If you are all set with this could you close the question as appropriate?

http://support.experts-exchange.com/customer/en/portal/articles/2527982-how-do-i-close-my-question-


»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.