Solved

List file names in Excel

Posted on 2004-04-13
6
256 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

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…
One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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