Discussion:
Problems Listing Certain Filetypes Within A Directory And Subdirectories
(too old to reply)
Accu Backup
2023-03-21 19:08:44 UTC
Permalink
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...

C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"

or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
Kerr-Mudd, John
2023-03-21 19:31:50 UTC
Permalink
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
Post by Accu Backup
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
Your option slashes are the wrong way round! Untested:

dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
--
Bah, and indeed Humbug.
Zaidy036
2023-03-21 20:55:21 UTC
Permalink
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
Post by Accu Backup
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?

In Windows batch:
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
Kerr-Mudd, John
2023-03-21 21:16:15 UTC
Permalink
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
Post by Accu Backup
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Accu Backup
2023-03-22 12:22:05 UTC
Permalink
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Thank you for the help. The \*. usage I found here...
https://www.howtogeek.com/363639/how-to-use-the-dir-command-in-windows/
near the end of the article. This is working. How can I modify these to DELETE the found files and EXCLUDE found files that may be in certain sub-folders in this directory? For example, this folder has many folders named Methods within it and I may not want to delete .txt files that are found in any Methods folder.
Zaidy036
2023-03-22 15:07:35 UTC
Permalink
Post by Accu Backup
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Thank you for the help. The \*. usage I found here...
https://www.howtogeek.com/363639/how-to-use-the-dir-command-in-windows/
near the end of the article. This is working. How can I modify these to DELETE the found files and EXCLUDE found files that may be in certain sub-folders in this directory? For example, this folder has many folders named Methods within it and I may not want to delete .txt files that are found in any Methods folder.
Now you are getting more complicated and with delete options you need
careful logic design. A FOR inside a FOR with the first rejecting
further processing if it is in a Methods folder while the second FOR
does the deletes. I suggest design and test runs using DIR instead of
DEL to make sure you are getting the results you expect. FORFILES may be
useful. If your folder structure has no branches but is one long string
could start at bottom(last) and use ".." to back out of each Folder.
Using /S may not permit rejecting "Methods" and you may have to step
thru so can reject it.
Accu Backup
2023-03-24 12:02:02 UTC
Permalink
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Thank you for the help. The \*. usage I found here...
https://www.howtogeek.com/363639/how-to-use-the-dir-command-in-windows/
near the end of the article. This is working. How can I modify these to DELETE the found files and EXCLUDE found files that may be in certain sub-folders in this directory? For example, this folder has many folders named Methods within it and I may not want to delete .txt files that are found in any Methods folder.
Now you are getting more complicated and with delete options you need
careful logic design. A FOR inside a FOR with the first rejecting
further processing if it is in a Methods folder while the second FOR
does the deletes. I suggest design and test runs using DIR instead of
DEL to make sure you are getting the results you expect. FORFILES may be
useful. If your folder structure has no branches but is one long string
could start at bottom(last) and use ".." to back out of each Folder.
Using /S may not permit rejecting "Methods" and you may have to step
thru so can reject it.
Thanks.
Zaidy036
2023-03-24 15:17:53 UTC
Permalink
Post by Accu Backup
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Thank you for the help. The \*. usage I found here...
https://www.howtogeek.com/363639/how-to-use-the-dir-command-in-windows/
near the end of the article. This is working. How can I modify these to DELETE the found files and EXCLUDE found files that may be in certain sub-folders in this directory? For example, this folder has many folders named Methods within it and I may not want to delete .txt files that are found in any Methods folder.
Now you are getting more complicated and with delete options you need
careful logic design. A FOR inside a FOR with the first rejecting
further processing if it is in a Methods folder while the second FOR
does the deletes. I suggest design and test runs using DIR instead of
DEL to make sure you are getting the results you expect. FORFILES may be
useful. If your folder structure has no branches but is one long string
could start at bottom(last) and use ".." to back out of each Folder.
Using /S may not permit rejecting "Methods" and you may have to step
thru so can reject it.
Thanks.
another option is to use XCOPY <source path> <destination FOLDER\> /T /E
which will copy folder layout without data and then use that FOLDER as
batch one-at-a-time folder choice to do what you want.
Accu Backup
2023-03-27 10:43:28 UTC
Permalink
Post by Zaidy036
Post by Accu Backup
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 16:55:21 -0400
Post by Zaidy036
Post by Kerr-Mudd, John
On Tue, 21 Mar 2023 12:08:44 -0700 (PDT)
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
dir "e:\shareddata\folder1\folder2" \*.txt \*.csv /s /b
Besides the error mentioned I am confused by the \*. usage. Is that a
server method or did you mean to use some form of "FOR" and that is a
shorthand?
FOR %f IN (txt csv) DO DIR "e:\shareddata\folder1\folder2\*.%f" /S /B
-or-
DIR "e:\shareddata\folder1\folder2\*.txt" /S /B
DIR "e:\shareddata\folder1\folder2\*.csv" /S /B
That looks much better!
--
Bah, and indeed Humbug.
Thank you for the help. The \*. usage I found here...
https://www.howtogeek.com/363639/how-to-use-the-dir-command-in-windows/
near the end of the article. This is working. How can I modify these to DELETE the found files and EXCLUDE found files that may be in certain sub-folders in this directory? For example, this folder has many folders named Methods within it and I may not want to delete .txt files that are found in any Methods folder.
Now you are getting more complicated and with delete options you need
careful logic design. A FOR inside a FOR with the first rejecting
further processing if it is in a Methods folder while the second FOR
does the deletes. I suggest design and test runs using DIR instead of
DEL to make sure you are getting the results you expect. FORFILES may be
useful. If your folder structure has no branches but is one long string
could start at bottom(last) and use ".." to back out of each Folder.
Using /S may not permit rejecting "Methods" and you may have to step
thru so can reject it.
Thanks.
another option is to use XCOPY <source path> <destination FOLDER\> /T /E
which will copy folder layout without data and then use that FOLDER as
batch one-at-a-time folder choice to do what you want.
The folder structure is deep and complex. Also, there are 2.5 TB of data in the structure I need to look through. Thanks.
mokomoji
2023-04-24 15:33:00 UTC
Permalink
I'm trying to output a list of all .txt and .csv files located within a certain directory and all its subdirectories. On Windows Server 2019, I'm running...
C:\>dir "e:\shareddata\folder1\folder2" \*.txt \*.csv \s \b > "c:\users\username\desktop\output.txt"
or similar variants and getting mixed results. When I have the \s included, I am getting ALL files... not just the ones I want. I also got only the wanted files but on the entire drive... not just from the folder I need. What am I missing here? My goal is to review the list of files and then use a similar batch to delete them if there is nothing I need to keep. Thanks.
same question as you
https://kin.naver.com/qna/detail.naver?d1id=1&dirId=10206&docId=443061337&page=1#answer1
Loading...