English 中文(简体)
DOS BAT 相当于统一基名指挥的档案?
原标题:DOS BAT file equivalent to Unix basename command?

采用监督事务司BAT指挥语言向监督事务司档案名称的基名(档案名称没有延伸)看是否容易?

我同意:format c:可能是一个良好的开端,随后是一只可boot的六氯环己烷CD(假设这些古董机器有一个CD读器,而不是一个特定的)。 但愿预示,我们只有监督事务司......。 (That means: notWindows - not 甚至是Windows 3.1, 更不用说Windows 95, 98, NT, ME, XP,ista, 7, 等)

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 指挥线

for /F %i in ("c:fooar.txt") do @echo %~ni

<For.bat files

for /F %%i in ("c:fooar.txt") do @echo %%~ni

页: 1

如果路径包含一个空间,则在<条码>中添加“delims=”等:

for /F "delims=" %i in ("c:fooar baz.txt") do @echo %~ni

页: 1

(Further Reading: http://www.computerhope.com/forhlp.htm )

问题回答

ars的回答中,此处引自 编码起帮助的相关分号。 指挥:

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~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
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

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
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.

我的理解是,答案“你可以 t”还不够。 因此,如果真的在“真正模式的监督事务司”中进行,那么,它就会得到4个业务司的指挥员和陪同方案,而不是“COMMAND”。 目 录

rel=“nofollow”>http://www.4dos.info/v4dos.htm

I haven t used it in years, but it was always /far/ better than COMMAND.COM If you search this page: http://www.4dos.info/4batfaq.htm for "basename" you will see there is a Real Mode DOS answer to your problem if using 4DOS /instead/ of COMMAND.COM

我认为,唯一的其他解决办法是找到或写出一个真正模式,即履行基名。

COMMAND.COM,即使是在监督事务司的6.22处,也与其所有支持的外部指挥机构一道,总是在文字/批量档案方面受到难以置信的破坏。 请注意,MinGW32指挥线的推进无济于事。 所有这些都属于受保护模式(32个视窗)。 如果你在监督事务司中尝试,你就只能获得加密“不能在监督事务司的温和或类似情况下操作这一方案”。

Full-working solution (even when path contains spaces)

<>file

for /F "delims=" %%i in (%FILE_path%) do @echo "%%~ni"

<<>t>-prompt> > ><>>>>>>>>>>>>><>%<>>>>>>>>>

<thanks to @Ciantic>

此外,MKS工具包有一个基名使用......

http://www.mkssoftware.com/docs/man1/basename.1.asp

监督事务司6.22不支持%~n 页: 1 我在最初的问题中提出的关于4.10条bcheck效用的问题,只需要一个基数,而Aql 2.10 bcheckutil则用饥饿。 饥饿是一个论点。 我制定了以下质量评估方案,以解决目前只需要一个基本名称才能工作的4.10节制:

BatFile$ = "CHKFILE.BAT"
        IF INSTR(COMMAND$, "?") > 0 THEN
          PRINT
          PRINT "This program generates a batch file to check Informix files"
          PRINT "  -b  BBBB.BAT    this option is used to change the batch file name"
          PRINT "                  by default the batch file name is CHKFILE.BAT"
          PRINT
          SYSTEM
        END IF
        IF INSTR(COMMAND$, "-B") > 0 THEN
          BatFile$ = LTRIM$(MID$(COMMAND$, INSTR(COMMAND$, "-B") + 2)) + "  "
          BatFile$ = LEFT$(BatFile$, INSTR(BatFile$, " ") - 1)
        END IF

        OPEN BatFile$ FOR OUTPUT AS #2


        filename$ = DIR$("*.dat")
        IF LEN(filename$) = 0 THEN SYSTEM
        DO WHILE LEN(filename$) > 0
          PRINT #2, "bcheck -y", filename$
          filename$ = DIR$
        LOOP
        CLOSE
        SYSTEM

OR可以撰写一个自动取款机方案,从机器中提取基名。 dirpath and PRINT “BCHECK -y”,systables.dirpath

根据 here博的公认答案,你如何利用指挥系统在批量档案中设定变数:

for /F %%i in ("%1") do @set FN=%%~nxi

它使用第1条指挥线论点,1 并将变数的FN与基数相等(例如档案)。

http://www.robvanderwoude.com/battech_fileproperties.php“rel=“nofollow noreferer”>FOR。 左翼指挥器可使用%~n





相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....