use this   one

Public f As Object, d As Object, sw As Object
Sub Main()

    Dim Fso As Object
    Set sw = CreateObject("Scripting.FileSystemObject")
    Set Fso = CreateObject("Scripting.FileSystemObject")
    Set RootFolder = Fso.GetFolder("C:\Documents and
Settings\ashish\Desktop\ashish koul")
    FolderRead RootFolder
End Sub
Sub FolderRead(ByRef myFolder)


   For Each f In myFolder.Files
    Var = f.Path
    If Right(f.Name, 4) = ".xls" Or Right(f.Name, 5) = ".xlsx" Then

  sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\excel\"

'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\excel\"
       End If


           If Right(f.Name, 5) = ".jpeg" Then
sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\jpeg\"
'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\jpeg\"
       End If

                If Right(f.Name, 4) = ".pdf" Then

sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\pdf\"

'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\pdf\"
       End If

   Next f
   For Each d In myFolder.SubFolders
     FolderRead d
   Next d
End Sub


On Sat, May 14, 2011 at 12:19 PM, ashish koul <koul.ash...@gmail.com> wrote:

> use move to move files and copy to copy the files
>
>
> Public f As Object, d As Object
> Sub Main()
>
>     Dim Fso As Object
>     Set Fso = CreateObject("Scripting.FileSystemObject")
>     Set RootFolder = Fso.GetFolder("C:\Documents and
> Settings\ashish\Desktop\ashish koul")
>     FolderRead RootFolder
> End Sub
> Sub FolderRead(ByRef myFolder)
> Dim sw As Object
> Set sw = CreateObject("Scripting.FileSystemObject")
>    For Each f In myFolder.Files
>     Var = f.Path
>     If Right(f.Name, 4) = ".xls" Or Right(f.Name, 5) = ".xlsx" Then
>
>   sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\excel\"
>
> 'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\excel\"
>        End If
>
>
>            If Right(f.Name, 5) = ".jpeg" Then
> sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\jpeg\"
> 'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\jpeg\"
>        End If
>
>                 If Right(f.Name, 4) = ".pdf" Then
>
> sw.copyFile f.Path, "C:\Documents and Settings\ashish\Desktop\pdf\"
>
> 'sw.MoveFile f.Path, "C:\Documents and Settings\ashish\Desktop\pdf\"
>        End If
>
>    Next f
>    For Each d In myFolder.SubFolders
>      FolderRead d
>    Next d
> End Sub
>
>
>
>
> On Sat, May 14, 2011 at 7:15 AM, Rafael Bruno <reservagra...@gmail.com>wrote:
>
>> Hi friends,
>>
>> I have a simple request that it's confusing me. I have a folder (let's
>> call "c:\motherfolder\"), that has thousands of subfolders. In each
>> subfolder there are 3 files: 1 .pdf, 1 excel (may be .xls or .xlsx), and 1
>> .jpeg.
>> I need to copy all pdfs to one folder (let's say "c:\pdfs_folder\"), all
>> excel files to another, and all jpegs to another.
>>
>> Can it be done? A long time ago (years) I remember doing something
>> similar, but only with .xls files (and even this I can't remember how).
>>
>> Thanks in advance,
>> Rafael
>> WebRep
>> Overall rating
>>
>>
>> --
>>
>> ----------------------------------------------------------------------------------
>> Some important links for excel users:
>> 1. Follow us on TWITTER for tips tricks and links :
>> http://twitter.com/exceldailytip
>> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
>> 3. Excel tutorials at http://www.excel-macros.blogspot.com
>> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
>> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
>>
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> <><><><><><><><><><><><><><><><><><><><><><>
>> Like our page on facebook , Just follow below link
>> http://www.facebook.com/discussexcel
>>
>
>
>
> --
> *Regards*
> * *
> *Ashish Koul*
> *akoul*.*blogspot*.com <http://akoul.blogspot.com/>
> *akoul*.wordpress.com <http://akoul.wordpress.com/>
> My Linkedin Profile <http://in.linkedin.com/pub/ashish-koul/10/400/830>
>
>
> P Before printing, think about the environment.
>
>
>


-- 
*Regards*
* *
*Ashish Koul*
*akoul*.*blogspot*.com <http://akoul.blogspot.com/>
*akoul*.wordpress.com <http://akoul.wordpress.com/>
My Linkedin Profile <http://in.linkedin.com/pub/ashish-koul/10/400/830>


P Before printing, think about the environment.

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to