পোস্টে
ব্যাচ এক্সট্র্যাক্টের পথ এবং একটি ভেরিয়েবলের ফাইলের নাম
একটি পরিবেশের ভেরিয়েবল থেকে সমস্ত ফাইল-অংশ বের করার জন্য এই স্ক্রিপ্টটি পাওয়া যায়:
@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
)
এবং .batস্ক্রিপ্টের প্রথম প্যারামিটার থেকে তথ্য আহরণের সম্পূর্ণ তালিকা :
%~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
যা ব্যবহার করা যেতে পারে, উদাহরণস্বরূপ:
set file=%~f1
set filepath=%~dp1
set filename=%~nx1
অথবা স্থানীয় হিসাবে পরিবর্তনশীল জন্য:
for %%a in (..\Desktop\fs.cfg) do (
set file=%%~fa
set filepath=%%~dpa
set filename=%%~nxa
)