• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Move Doc files from multiple folders in same drive into one folder.

Jagdev Singh

Active Member
Hi Experts,
Please let me know if this is possible with excel VBA which will move doc files from same drive and same main folder. The main folder contains 4 sub-folders with doc files in it. I need these entire doc files in a single folder is this possible?
Regards,
JD
 
Can use VBA\vbs\bat and so on

it's bat file below,copy and paste into notepad,save as a bat file
replace the path of mainfolder and destfolder as your path
Code:
@echo off
set mainfolder=d:\aaaa
set destfolder=e:\bb

for /f "delims=" %%i in ('dir /b/s "%mainfolder%\*.doc*"') do (
  call move "%%i" "%%destfolder%%\%%~nxi"
)
echo Completed !!&&pause>nul
 

Attachments

  • run me.zip
    305 bytes · Views: 4
or if it's a one-off

Goto Windows Explorer
Find the Main Folder
In the Search Box (Top Right Corner) search for *.doc*
When it has finished searching
Select Any File
Ctrl A
Right Click on any file - Cut or Ctrl+X

Move to the new Folder
Right Click in the folder and select Paste or Ctrl+V
 
Hi Both

The below code does the same task via excel

Code:
Sub blah()
PathArray = Array("E:\test1\Subfolder1\", "E:\test1\Subfolder2\", "E:\test1\Subfolder3\", "E:\test1\Subfolder4\")
For Each oldpath In PathArray
  newpath = "E:\test2\"
  Fname = Dir(oldpath & "*.doc*")
  Do While Fname <> ""
    Name oldpath & Fname As newpath & Fname
    Fname = Dir
  Loop
Next oldpath
End Sub

Regards,
JD
 
JD

Have you searched on an Word Blogs ?
I am sure that has been answered more appropriately in them
 
Back
Top