Is this possible

  • Thread starter Thread starter Hans Thurston
  • Start date Start date
H

Hans Thurston

I want to make a list of the files in several different
folders. Is it possible to somehow "Copy and paste" just
the filenames into a list, in either Word or Excel or
Wordperfect. I am just trying to sort the files in
several different folders to weed out duplicates. There
has got to be an easier way then typing them all or screen
printing the lists and manually weeding them out. Any
suggestions.
Frustrated...
 
Hans,

Here is some code that will start in a directory and list all files in that
and any sub directories. It uses recursion to go through all the subs.

Just change the start directory

Dim oFSO As Object
Dim cFiles As Long

Sub ListFiles()

Set oFSO = CreateObject("Scripting.FileSystemObject")

cFiles = 1

SelectFiles "D:\Bob"

End Sub

'---------------------------------------------------------------------------
Sub SelectFiles(sPath)
'---------------------------------------------------------------------------
Dim oFolder As Object, oSubFolder As Object
Dim oFiles As Object, oFile As Object

Set oFolder = oFSO.GetFolder(sPath)
Set oFiles = oFolder.Files

For Each oFile In oFiles
Cells(cFiles, 1).Value = oFile.Path
cFiles = cFiles + 1
Next

For Each oSubFolder In oFolder.Subfolders
SelectFiles oSubFolder.Path
Next

End Sub
 
Click on file name, so it is highlighted blue. Then click
agian, like you would rename it. Now you can select what
part of file name you want & hit CRTL + C. Take it to new
file and paste new file name.
 
Back
Top