Move names from Search to Excel

M

Mark1

I did a search in windows explorer for all files that contain the text "X".
I want to be able to move the list of named files to an excel worksheet. In
other words, if my search results displayed these files containing the text
"X":
ABCD
EFGH
IJKLM

I want my Excel spreadsheet to look like this:
ABCD
EFGH
IJKLM

Thanks for the help!
 
R

Ron Coderre

Maybe this quick non-vba solution?
(it's a lot easier to do than to describe)

Open notepad and enter a line similar to this:
dir/b \\MyServer\MyFolder\*X*.xl* >> c:\MyFileList.txt

Save the notepad file on your Desktop as ListFiles.BAT

Double-click that file to run it and create the list

Open the C:\MyFileList.txt file and copy the list into Excel
or just import it into Excel

-----------------
Notes:
dir/b :is the command to list files (excluding headings, details, and
summaries)

\\MyServer\MyFolder\*X*.xl* :indicates where to look and what to list.
In this case, it looks in the MyFolder folder of the MyServer server for
Excel files whose file name contains an "X". You'll enter the correct
location. If you are searching your C:drive, you'd use this version of the
command:
dir/b C:\MyFolder\*X*.xl* >> c:\MyFileList.txt

This section: >> c:\MyFileList.txt
is the command to write the search results to a text file named
MyFileList.txt and store that file in the root of the C: drive.
-----------------


Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP
 
M

Mark1

Thank you Ron, that is exactly what I needed. I was going through DOS help
webpages trying to find the exact syntax. Thanks again!
 
R

Ron Coderre

You're very welcome...Thanks for the feedback.

(It's not often that I have to sort through my mind's seldom used DOS closet
looking for not quite forgotten commands!)

***********
Regards,
Ron

XL2002, WinXP
 
M

Mark1

Ron,
One more thing, and it might be a biggie. I need to list out files where
the contents contain "X", not the actual file name. This is what I tried
before your original reply:

C:\>FINDSTR /M "X*" \\MYSERVER\MYPATH

but with no luck. I'm going to try to incorporate what you wrote earlier
and see what I get. In the meantime, if you have the modification that would
be great.
 
R

Ron Coderre

Regarding: FINDSTR /M "X*" \\MYSERVER\MYPATH

If you intend the asterisk to be a wildcard...that's the wrong wildcard.
You'd need to create a regular expression for the search.

FINDSTR /M "X" \\MYSERVER\MYPATH
will find files that contain "X"

Also, from my playing with the FINDSTR command....
To find files with lines that begin with "X"...use:
FINDSTR /M/B "X" \\MYSERVER\MYPATH

However, if you're doing that search in Excel files, they're not constructed
like a plain text file. So, finding the beginning of a line may be an issue.
Example:
1) I built an Excel file that only contained "applejacks" in cell A1 and
saved the file as C:\DeleteMe.xls
2) I searched: FINDSTR /B "APPLE" C:\*.XLS
--->result: no match
3) I searched: FINDSTR "APPLE" C:\*.XLS
-->result: c:\deleteme.xls:...applejacks

Use this command to see a list of all FINDSTR parameters and syntax:
FINDSTR /?

I hope that helps.
***********
Regards,
Ron

XL2002, WinXP
 

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