Batch File dir to .txt file

April 29, 2011 at 12:11:33
Specs: Windows Vista
I found a way to make a list of files in a directory from the following site:
//www.theeldergeek.com/file_list_generator.htm

However, what I would like to do is put the resulting .txt file into a particular directory and use the name of the target directory as the .txt file name. This is what I have so far:
@echo off
dir %1 /a /b /-p /o:gen >"C:\MyDowners\_Files.txt"

What I need to know is how to add the %1 before the '_Files.txt'??

I've tried using & in different methods:
"C:\MyDowners\" & %1 & "_Files.txt"
"C:\MyDowners\ & %1 & _Files.txt"

As well as:
"C:\MyDowners\" %1 "_Files.txt"
"C:\MyDowners\%1_Files.txt"

Nothing I'm doing is working. Any help would be appreciated!

Peace to you and yours,
Matthew "Dra'Gon" Stohler


See More: Batch File dir to .txt file

Report •


#1
April 29, 2011 at 13:40:33

dir %1 /a /b /o:gen > "C:\MyDowners\%~n1_Files.txt"


Report •

#2
April 29, 2011 at 16:29:30
Oh EXCELLENT!

Thank you very much for your help, IVO!!!!

Peace to you and yours,
Matthew "Dra'Gon" Stohler


Report •
Related Solutions


Ask Question