Is this possible

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...
 
B

Bob Phillips

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
 
T

Tom

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top