Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch find file extension

If I am iterating over each file using :

@echo off

FOR %%f IN (*\*.\**) DO (
    echo %%f
)

how could I print the extension of each file? I tried assigning %%f to a temporary variable, and then using the code : echo "%t:~-3%" to print but with no success.

like image 670
Vhaerun Avatar asked Sep 26 '08 11:09

Vhaerun


1 Answers

The FOR command has several built-in switches that allow you to modify file names. Try the following:

@echo off
for %%i in (*.*) do echo "%%~xi"

For further details, use help for to get a complete list of the modifiers - there are quite a few!

like image 97
Sam Holloway Avatar answered Nov 10 '22 14:11

Sam Holloway