Toplu İş Sonrası
yolunda ve bir değişkenden gelen dosya adında
bir ortam değişkeninden tüm dosya bölümlerini çıkarmak için bu komut dosyası bulunur:
@ECHO OFF
SETLOCAL
set file=C:\Users\l72rugschiri\Desktop\fs.cfg
FOR %%i IN ("%file%") DO (
ECHO filedrive=%%~di
ECHO filepath=%%~pi
ECHO filename=%%~ni
ECHO fileextension=%%~xi
)
Ve .batbetiğin ilk parametresinden bilgi çıkarmak için tam liste :
%~1 - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
Örneğin hangisi kullanılabilir?
set file=%~f1
set filepath=%~dp1
set filename=%~nx1
Veya yerel bir FOR değişkeni olarak:
for %%a in (..\Desktop\fs.cfg) do (
set file=%%~fa
set filepath=%%~dpa
set filename=%%~nxa
)