You can run following examples individually to learn about file modifiers.
Example
@echo off
REM List filename of each batch file, file modifier is not used here
FOR %%f in (*.bat) DO echo %%f
pause
Example
@echo off
REM
FOR %%f in (*.bat) DO echo %%~nf
pause
Example
@echo off
REM
FOR %%f in (*) DO echo %%~xf
pause
Example
@echo off
REM
FOR %%f in (*.bat) DO echo %%~nxf
pause
Example
@echo off
REM
FOR %%f in (*.bat) DO echo %%~ff
pause
Example
@echo off
REM
FOR %%f in (*.bat) DO echo %%~pf
pause
Example: This example shows the usage in one script.
Tips: To get the complete list of file modifier, run the command FOR/?
|
%~I |
expands %I removing any
surrounding quotes (") |
|
%~fI |
expands %I to a fully
qualified path name |
|
%~dI |
expands %I to a drive letter
only |
|
%~pI |
expands %I to a path only |
|
%~nI |
expands %I to a file name only |
|
%~xI |
expands %I to a file extension
only |
|
%~sI |
expanded path contains short
names only |
|
%~aI |
expands %I to file attributes
of file |
|
%~tI |
expands %I to date/time of
file |
|
%~zI |
expands %I to size of file |
No comments:
Post a Comment