SORU
18 Mart 2009, ÇARŞAMBA


Nasıl CMD ile dosya yolundan klasör yolunu almak için

Cmd dosyası içeren klasörü için yol lazım. %0 ile dosya adını verebilirim. Ama nasıl klasör adını almak için?

P. S. Benim şimdiki dizin=! script klasörü.

CEVAP
18 Mart 2009, ÇARŞAMBA


Klasör adı ve sürücü için kullanabilirsiniz:

echo %~dp0

Daha fazla bilgi farklı değiştiricileri kullanarak alabilirsiniz:

%~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

The modifiers can be combined to get compound results:
%~dpI       - expands %I to a drive letter and path only
%~nxI       - expands %I to a file name and extension only
%~fsI       - expands %I to a full path name with short names only

Bu bir kopyala/? komut istemini komut. boyunca yapıştırın. Umarım yardımcı olur.

İlgili

Top 10 DOS Batch tips (Yes, DOS Batch...) batchparams.bat (esas olarak bağlantı kaynağı gösterir:

C:\Temp>batchparams.bat c:\windows\notepad.exe
%~1     =      c:\windows\notepad.exe
%~f1     =      c:\WINDOWS\NOTEPAD.EXE
%~d1     =      c:
%~p1     =      \WINDOWS\
%~n1     =      NOTEPAD
%~x1     =      .EXE
%~s1     =      c:\WINDOWS\NOTEPAD.EXE
%~a1     =      --a------
%~t1     =      08/25/2005 01:50 AM
%~z1     =      17920
%~$PATHATH:1     =
%~dp1     =      c:\WINDOWS\
%~nx1     =      NOTEPAD.EXE
%~dp$PATH:1     =      c:\WINDOWS\
%~ftza1     =      --a------ 08/25/2005 01:50 AM 17920 c:\WINDOWS\NOTEPAD.EXE

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • BroadCity

    BroadCity

    10 ŞUBAT 2010
  • DudeFromUkraine

    DudeFromUkra

    7 Ocak 2008
  • vgeller1

    vgeller1

    22 Kasım 2009