Solved

List file names in Excel

Posted on 2004-04-13
6
253 Views
Last Modified: 2010-04-13
I have a folder that stores images (jgs, tif, etc.) of forms that have been scanned. Each form is related to ONE of our customers, so we have named each image file as the CustomerID.

For example I have some files named:

34568.jpg
146.tif
267897.jpg
7654.tif
679839.tif
...

I need to create an excel file (or text file) with a list of all the IDs of the file names that have been stored. So, for the above I need an excel file that has entries:

34568
146
267897
7654
679839

Is there any way of doing this? Thanks.
0
Comment
Question by:naqayya
  • 3
  • 2
6 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 10814472
Assuming that there are no duplicates (1234.jpg and 1234.tif), and those files are in a single directory, simply enter
for %a in (*.*) do @echo %~na >>"S:\ome\Directory\id.txt"
which will create the file "id.txt" (delete the file if it exists before issuing in a command).
That can of course be put into a batch file as well:

@echo off
set OutFile=S:\ome\Directory\id.txt
if exist "%OutFile%" del "%OutFile%"
for %%a in (*.*) do echo %%~na >>"%OutFile%"

For additional goodies, you need to provide more information...
0
 

Author Comment

by:naqayya
ID: 10814674
Thanks oBdA!

I am a bit of a novice here: do I enter this command from a command prompt on the PC and do I have to be in the directory that has the files?

Thanks.
0
 

Author Comment

by:naqayya
ID: 10814766
How do I go to that directory in the command prompt? I need to get files from:
E:\GADs\0 - 50,000

(note the spaces and comma in the directory name)

Thanks!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 16

Expert Comment

by:JamesDS
ID: 10814840
naqayya

If this is just a one off then you could just run the following from the command line (in the right directory!)

dir /b > output.txt

The file output.txt will contain your filenames which can be imported into Excel.
You can strip off the externsion in Excel by adding a formula into the next column over from your list that goes:
=MID(A1,1,LEN(A1)-4)

Where A1 is the first cell of your list.
Copy the formula down and use the new column as your start data

Cheers

JamesDS
0
 
LVL 83

Accepted Solution

by:
oBdA earned 200 total points
ID: 10814871
To run it in the command prompt, simply enter
E:
cd "\gads\0 - 50,000"
for %a in (*.*) do @echo %~na >>"S:\ome\Directory\id.txt"

or, directly in one single command:
for %a in ("E:\gads\0 - 50,000\*.*") do @echo %~na >>"S:\ome\Directory\id.txt"

Or put it all in a batch file:

====8<----[GetIDs.cmd]----
@echo off
setlocal
set OutFile=S:\ome\Directory\id.txt
set RootDir=E:\GADs\0 - 50,000
if exist "%OutFile%" del "%OutFile%"
for %%a in ("%RootDir%\*.*") do echo %%~na >>"%OutFile%"
====8<----[GetIDs.cmd]----
0
 

Author Comment

by:naqayya
ID: 10821881
Thanks all
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now