DOS BAT file equivalent to Unix basename command?

For command-line

for /F %i in ("c:\foo\bar.txt") do @echo %~ni

For .bat Files

for /F %%i in ("c:\foo\bar.txt") do @echo %%~ni

output: bar

If the path contains a space, add in "delims=" like so:

for /F "delims=" %i in ("c:\foo\bar baz.txt") do @echo %~ni

output: bar baz

(Further Reading:
http://www.computerhope.com/forhlp.htm )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)