jhieb
asked on
Find files through command line
Hello,
I am looking for a DOS command line utility that can find files based upon criteria (such as file extension), and put the results into a CSV file. For example, if I want to find files with the DOC extension, I would like for the utility to return two values in the CSV file. The first value would be the path, and the second value would be the filename.
If you know of a utility like this then please let me know where I can download it from.
Thank you,
John
I am looking for a DOS command line utility that can find files based upon criteria (such as file extension), and put the results into a CSV file. For example, if I want to find files with the DOC extension, I would like for the utility to return two values in the CSV file. The first value would be the path, and the second value would be the filename.
If you know of a utility like this then please let me know where I can download it from.
Thank you,
John
ASKER
Thank you. That is what I normally do right now, except I do not user /P and I use /B in order to get the basic output, which gives me the path. This is very close to what I want, but I would also like to have the path and filename in separate values. I will leave this open for a while to see if there is anything else. If not, this is still a great answer. Thanks.
Great!, Below you will find all the attributes you can use with the above command I posted
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files I Not content indexed files
L Reparse Points - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/R Display alternate data streams of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting
timefield C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file
names. The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4 Displays four-digit years
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files I Not content indexed files
L Reparse Points - Prefix meaning not
/B Uses bare format (no heading information or summary).
/C Display the thousand separator in file sizes. This is the
default. Use /-C to disable display of separator.
/D Same as wide but files are list sorted by column.
/L Uses lowercase.
/N New long list format where filenames are on the far right.
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
/P Pauses after each screenful of information.
/Q Display the owner of the file.
/R Display alternate data streams of the file.
/S Displays files in specified directory and all subdirectories.
/T Controls which time field displayed or used for sorting
timefield C Creation
A Last Access
W Last Written
/W Uses wide list format.
/X This displays the short names generated for non-8dot3 file
names. The format is that of /N with the short name inserted
before the long name. If no short name is present, blanks are
displayed in its place.
/4 Displays four-digit years
ASKER
Thanks. I can get the switches just by using DIR /? at the command prompt.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi oBdA, this is exactly what I was looking for, and it works perfectly.
Just saw your VB script question, so for the sake of completeness: if you want the extension separately, just replace "%~nxa" with "%~na,%~xa":
(for /r "C:\Temp" %a in (*.doc) do @echo %~dpa,%~na,%~xa)>test.csv
(for /r "C:\Temp" %a in (*.doc) do @echo %~dpa,%~na,%~xa)>test.csv
ASKER
Thanks, I posted that question before your response.
I tested this by searching my primary drive for DOC files, and came up with quite a list. Two things came to mind. One, is that there might be files with a comma in the name. So, is it possible to change the delimiter to a semi-colon rather than a comma? Then, I wonder if it is more practical to turn the path into an 8.3 path rather than a long pathname. if so, could that be done in this command?
I tested this by searching my primary drive for DOC files, and came up with quite a list. Two things came to mind. One, is that there might be files with a comma in the name. So, is it possible to change the delimiter to a semi-colon rather than a comma? Then, I wonder if it is more practical to turn the path into an 8.3 path rather than a long pathname. if so, could that be done in this command?
To change the delimiter, just change the commas in the "echo" part to semicolons:
(for /r "C:\Temp" %a in (*.doc) do @echo %~dpa;%~na;%~xa)>test.csv
To generate a short file name, add a "s" as first character after the "~" (but I wouldn't call it practical):
(for /r "C:\Temp" %a in (*.doc) do @echo %~sdpa;%~sna;%~xa)>test.cs v
(for /r "C:\Temp" %a in (*.doc) do @echo %~dpa;%~na;%~xa)>test.csv
To generate a short file name, add a "s" as first character after the "~" (but I wouldn't call it practical):
(for /r "C:\Temp" %a in (*.doc) do @echo %~sdpa;%~sna;%~xa)>test.cs
ASKER
I must be going blind. I didn't see the comma. Thanks again. This is exactly what I needed.
You have to open Command Prompt and Type following command
In order to finds all tmp files including subdirectories and pauses display by page.
I use the dir command
dir *.tmp /s /p
and you can export your result to a text file which then you can manupulate the output in excel to show only filename and path
dir *.tmp /s /p > "C:\Users\UserNAME\Desktop