mmatharu
asked on
search for file and create list in CSV using command prompt
How do I find all the files with a "9" in the filename in a folder and its sub-folders, with executing a command from cmd and then export that to a csv file as i tried using > c:\filelist.csv but this doesn't put a comma after each filename in the list.
The command i tried is:
dir /a-d /b C:\*_9_*.txt>filelist.csv
The command i tried is:
dir /a-d /b C:\*_9_*.txt>filelist.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
if i execute the dir command above "c:\dir /a /s *9* > c:\fileswith9.txt" it gives me the following out put, I just want a list of the filenames of the file with a specific number in this case i was using 9.
Volume in drive E has no label.
Volume Serial Number is 0C76-DFCA
Directory of E:\folder1\folder2\datafol der
08/19/2010 04:07 AM <DIR> .
08/19/2010 04:07 AM <DIR> ..
08/19/2010 07:47 AM <DIR> extract
08/19/2010 07:45 AM <DIR> full_extract
08/19/2010 07:48 AM <DIR> mapping
07/01/2010 11:02 AM <DIR> persist
08/19/2010 04:07 AM 2,762 policy_type.ds
08/19/2010 07:52 AM <DIR> staging
05/21/2010 10:00 AM 4,785 ZNNA_3.DS
05/21/2010 10:00 AM 7,669 ZUCO_3.DS
05/21/2010 10:00 AM 8,827 ZUMA_3.DS
05/21/2010 10:00 AM 7,387 ZUSF_3.DS
5 File(s) 31,430 bytes
Directory of E:\folder1\folder2\datafol der\extrac t
08/19/2010 07:47 AM <DIR> .
08/19/2010 07:47 AM <DIR> ..
07/09/2010 10:52 AM 3,286 Currency_0_Extract.ds
08/03/2010 09:59 AM 5,946 ICDCREP_0_Extract.ds
08/19/2010 06:41 AM 3,470 ICDCREP_30_Extract.ds
08/19/2010 07:45 AM 3,470 ICDCREP_32_Extract.ds
08/17/2010 09:53 AM 3,472 ICDCREP_9_Extract.ds
08/10/2010 09:35 AM 3,736 Reporting_Structure_5_Extr act.ds
08/19/2010 07:39 AM 3,144 ZACJDF00_34_Extract.ds
07/20/2010 10:47 AM 5,612 ZACJDF00_5_Extract.ds
08/03/2010 10:01 AM 5,860 ZHKTDF00_0_Extract.ds
08/19/2010 06:38 AM 3,378 ZHKTDF00_30_Extract.ds
08/19/2010 07:42 AM 3,376 ZHKTDF00_32_Extract.ds
Volume in drive E has no label.
Volume Serial Number is 0C76-DFCA
Directory of E:\folder1\folder2\datafol
08/19/2010 04:07 AM <DIR> .
08/19/2010 04:07 AM <DIR> ..
08/19/2010 07:47 AM <DIR> extract
08/19/2010 07:45 AM <DIR> full_extract
08/19/2010 07:48 AM <DIR> mapping
07/01/2010 11:02 AM <DIR> persist
08/19/2010 04:07 AM 2,762 policy_type.ds
08/19/2010 07:52 AM <DIR> staging
05/21/2010 10:00 AM 4,785 ZNNA_3.DS
05/21/2010 10:00 AM 7,669 ZUCO_3.DS
05/21/2010 10:00 AM 8,827 ZUMA_3.DS
05/21/2010 10:00 AM 7,387 ZUSF_3.DS
5 File(s) 31,430 bytes
Directory of E:\folder1\folder2\datafol
08/19/2010 07:47 AM <DIR> .
08/19/2010 07:47 AM <DIR> ..
07/09/2010 10:52 AM 3,286 Currency_0_Extract.ds
08/03/2010 09:59 AM 5,946 ICDCREP_0_Extract.ds
08/19/2010 06:41 AM 3,470 ICDCREP_30_Extract.ds
08/19/2010 07:45 AM 3,470 ICDCREP_32_Extract.ds
08/17/2010 09:53 AM 3,472 ICDCREP_9_Extract.ds
08/10/2010 09:35 AM 3,736 Reporting_Structure_5_Extr
08/19/2010 07:39 AM 3,144 ZACJDF00_34_Extract.ds
07/20/2010 10:47 AM 5,612 ZACJDF00_5_Extract.ds
08/03/2010 10:01 AM 5,860 ZHKTDF00_0_Extract.ds
08/19/2010 06:38 AM 3,378 ZHKTDF00_30_Extract.ds
08/19/2010 07:42 AM 3,376 ZHKTDF00_32_Extract.ds
You can use dir /a/s/b *9*.* > c:\9.txt
I have just done this and got the following output - it will always publish the path along with the file I think
C:\9.txt
C:\DELL\drivers\R190031
C:\DELL\drivers\R190974
C:\DELL\drivers\R191024
C:\DELL\drivers\R182522\Al l\915.cat
C:\DELL\drivers\R182522\Al l\915.inf
C:\DELL\drivers\R182522\Al l\915M.cat
C:\DELL\drivers\R190031\HD AQFE\win2k 3\us\kb901 105.exe
C:\DELL\drivers\R190031\WD M\92HDM4-1 .INI
C:\DELL\drivers\R190031\WD M\92HDM4-2 .INI
C:\DELL\drivers\R190031\WD M\92HDM4-3 .INI
C:\DELL\drivers\R190031\WD M\92HDM4-4 .INI
C:\DELL\drivers\R190031\WD M\92HDM4-5 .INI
C:\DELL\drivers\R190031\WD M\DellHDM9 .bld
C:\DELL\drivers\R194581\Dr ivers\w29n 50.sys
C:\DELL\drivers\R194581\Dr ivers\w29n 51.cat
C:\DELL\drivers\R194581\Dr ivers\w29n 51.inf
C:\DELL\drivers\R194581\Dr ivers\w29n 51.sys
C:\DELL\drivers\R197513\BT W3208\Win3 2\0x0409.i ni
C:\DELL\drivers\R197513\BT W3208\Win3 2\0x0419.i ni
C:\DELL\drivers\R197513\BT W3208\Win3 2\1029.mst
C:\DELL\drivers\R197513\BT W3208\Win3 2\1049.mst
C:\DELL\drivers\R197513\BT W3208\Win3 2\Lang\102 9
any better?
I have just done this and got the following output - it will always publish the path along with the file I think
C:\9.txt
C:\DELL\drivers\R190031
C:\DELL\drivers\R190974
C:\DELL\drivers\R191024
C:\DELL\drivers\R182522\Al
C:\DELL\drivers\R182522\Al
C:\DELL\drivers\R182522\Al
C:\DELL\drivers\R190031\HD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R190031\WD
C:\DELL\drivers\R194581\Dr
C:\DELL\drivers\R194581\Dr
C:\DELL\drivers\R194581\Dr
C:\DELL\drivers\R194581\Dr
C:\DELL\drivers\R197513\BT
C:\DELL\drivers\R197513\BT
C:\DELL\drivers\R197513\BT
C:\DELL\drivers\R197513\BT
C:\DELL\drivers\R197513\BT
any better?
ASKER
Yes thanks thats worked but do you know how i can output the list like this:
C:\9.txt,C:\DELL\drivers\R 190031,C:\ DELL\drive rs\R190974 ,C:\DELL\d rivers\R19 1024,C:\DE LL\drivers \R182522\A ll\915.cat ,C:\DELL\d rivers\R18 2522\All\9 15.inf,C:\ DELL\drive rs\R182522 \All\915M. cat
with a comma after each filename
C:\9.txt,C:\DELL\drivers\R
with a comma after each filename
No idea
ASKER
Thanks for the quick response, but that file will then be used by an automated process so I will not have the chance to open and edit the file.