0

I have 2 folders name FOLDER_ONE and FOLDER_TWO,now I want to copy all the files and folders from FOLDER_ONE and paste them into FOLDER_TWO and want to rename this FOLDER_TWO to FOLDER_ONE .Can any one tell me how can I do this by using vbs ???

1
  • You may not have meant to, but your question is effectively asking to merge two folders: copy all FOLDER1 files to FOLDER2, then rename FOLDER2 to FOLDER1, which deletes FOLDER2. Can you please clarify if this was your intention?
    – Lizz
    Sep 4, 2012 at 14:14

3 Answers 3

1

Run the following as a batch file:

move /-y "D:\example\original\*01*.txt" "D:\example\New folder\"

pause

The /-y is used to prompt if there are duplicates, and you can remove it if you don't care about over writing files.

This part "D:\example\original*01.txt"* we are defining the file(s) we will be moving. So in this example this will be any file that has 01 and .txt in its name. You will need to make sure you have the full path with “ “ around it.

This is where "D:\example\New folder\" we will be moving the file to. Once again make sure you have the “ “ around the full path if you have any spaces in the folder names.

0

In batch files you have a few options depending on your needs:

  • copy – good for copying a few files around but better keep it simple
  • xcopy – better copy allowing copying whole directory trees with complex criteria as to what to copy and what not
  • robocopy – similar to xcopy but with additional emphasis on resilience and automation. Supports theoretically everything that xcopy does but sometimes with slightly varying semantics.

All of those have extensive online help and plenty of examples around the web.

0

Why not just copy straight to FOLDER_THREE?

MD FOLDER_THREE
XCOPY FOLDER_ONE\*.* FOLDER_THREE /S

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.