Solved

List file names in Excel

Posted on 2004-04-13
6
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 85

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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 85

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
We take a look at some of the most common obstacles that IT teams run into as they work relentlessly to keep all the alarms and sirens from going off at once.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 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