DOS BAT file equivalent to Unix basename command?

前端 未结 8 1343
野趣味
野趣味 2020-12-03 00:43

Is there an easy way to get to the basename (file name without extension) of a DOS file name using the DOS BAT command language?

I agree: format c:\\ is

8条回答
  •  [愿得一人]
    2020-12-03 01:33

    DOS 6.22 does not support %~nI in for batch statements. here's a workaround to the problem I presented in my original question about isql's 4.10 bcheck utility requiring only a basename whereas in isql 2.10 bcheck utility worked with star.star as an argument. I created the following QBASIC program to solve bcheck 4.10 now requiring only a basename to work:

    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, one can write an ACE program to extract the basename from systables.dirpath and PRINT "BCHECK -y ",systables.dirpath

提交回复
热议问题