Solved

List file names in Excel

Posted on 2004-04-13
6
258 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 84

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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 84

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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