# list filenames without path by cmd file



## lampe73 (Nov 1, 2009)

I use the following command file to produce a path list via notepad++:

E:
set "Verz=\Music\Aufnahmen\VLC-Stick-Sicherung"
cd %Verz%
dir %Verz%\*.txt %Verz%\*.bat %Verz%\*.mp3 /b /s >TitellisteDOS.txt 
:: execute link file://E:/Music/VLC-Stream-Aufnahmen/VLC-Stick-Sicherung/DateinamensListe.bat

However what I really want is_ the same list_ _without the path directories_. Could anyone be so kind to modify the script or give me a respective hint?

Kind regards
lampe73


----------



## foxidrive (Oct 20, 2012)

```
@echo off
pushd "E:\Music\Aufnahmen\VLC-Stick-Sicherung"
(for /r %%a in (*.txt *.bat *.mp3) do echo "%%~nxa")>TitellisteDOS.txt
popd
:: execute link file://E:/Music/VLC-Stream-Aufnahmen/VLC-Stick-Sicherung/DateinamensListe.bat
```


----------



## lampe73 (Nov 1, 2009)

Thanks for your resonse. However, the script only produces the line
" - - - - - -"
for each of the 200 files. Correcting it is beyond my command of batch programming. Please try again.


----------



## foxidrive (Oct 20, 2012)

It's actually creating the file in the "E:\Music\Aufnahmen\VLC-Stick-Sicherung" folder

This modification creates the file in the same folder as the batch file.


```
@echo off
pushd "E:\Music\Aufnahmen\VLC-Stick-Sicherung"
(for /r %%a in (*.txt *.bat *.mp3) do echo "%%~nxa")>"%~dp0\TitellisteDOS.txt"
popd
```
The last line that I also removed wasn't needed, I'm not sure if you realise that.


----------



## lampe73 (Nov 1, 2009)

Sorry for my last post with misleading information. The '- - - - - - - - -' lines belonged to a different file.
Your script now generates the same list as my initial one, e. g. 

E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\001 Bach (Loussier), Italienisches-Konzert F-Dur, BWV 971.mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\002 Bach, Brandenburgisches Konzert Nr 3 G-Dur, BWV 1048.mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\003 Bach, Brandenburgisches Konzert Nr 4 G-Dur, BWV 1049.mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\004 Bach, Brandenburgisches Konzert Nr 5 D-Dur, BWV 1050.mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\005 Bach, Cello-Suite C-Dur, BWV 1009.mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\006 Bach, Die Kunst der Fuge, BWV 1080 (Glenn Gould, Orgel).mp3
E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung\Bach J S\007 Bach, Englische Suite g-Moll BWV 808(Dinnerstein).mp3
etc
All the directories are still there. 

My targeted list should contain the filenames only like
001 Bach (Loussier), Italienisches-Konzert F-Dur, BWV 971.mp3
002 Bach, Brandenburgisches Konzert Nr 3 G-Dur, BWV 1048.mp3
003 Bach, Brandenburgisches Konzert Nr 4 G-Dur, BWV 1049.mp3
004 Bach, Brandenburgisches Konzert Nr 5 D-Dur, BWV 1050.mp3
005 Bach, Cello-Suite C-Dur, BWV 1009.mp3
006 Bach, Die Kunst der Fuge, BWV 1080 (Glenn Gould, Orgel).mp3
007 Bach, Englische Suite g-Moll BWV 808(Dinnerstein).mp3
etc

At present I remove the diorectories by a search and replace action in notepad++ with the regex '.+\\'. Perhaps this, as an alternative method, can be done in the bat script after the loop?


----------



## foxidrive (Oct 20, 2012)

Delete the file from the current folder and try again.

It doesn't show the path, you're probably looking at an old file - you can double check the file date and time to be sure.


----------



## lampe73 (Nov 1, 2009)

You are totally right. I got lost in my own directory jungle.
Here is the final functional script:
:: To generate file list double click file://E:/Music/VLC-Stream-Aufnahmen/VLC-Stick-Sicherung/DateinamensListe.bat
@Echo off
pushd "E:\Music\VLC-Stream-Aufnahmen\VLC-Stick-Sicherung"
(for /r %%a in (*.txt *.bat *.mp3) do echo "%%~nxa")>"%~dp0\TitellisteDOS.txt"
popd

Last question: To understand your compact script, which of the many online batch tutorials would you recommend?

Many thanks again!


----------



## foxidrive (Oct 20, 2012)

lampe73 said:


> which of the many online batch tutorials would you recommend?


In the case of this script you can type

help pushd
help for
help popd

and reading the builtin help will give you an overview of the command and an idea on how it is implemented.

Some batch related forums and material

http://www.dostips.com/forum/
http://www.ss64.com/nt/index.html
http://www.robvanderwoude.com/
http://www.computerhope.com/forum/
http://stackoverflow.com
http://forums.techguy.org/23-dos-other/
http://www.netikka.net/tsneti/info/tscmd.php <--- tscmd.zip has many samples

Search these Usenet groups. Replace "your+keywords" with your keywords

alt.msdos.batch
alt.msdos.batch.nt
http://groups.google.com/groups?group=alt.msdos.batch.*&q=your+keywords


----------

