Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Is it possible to remove the colon from the drive letter  (Read 7943 times)

0 Members and 1 Guest are viewing this topic.

1963Ford

    Topic Starter


    Newbie

    Is it possible to remove the colon from the drive letter
    « on: January 26, 2009, 03:37:40 PM »
    Here's the code that I am working with:

    rem @echo off
    setlocal enable delayedexpansion
    for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "Removeable"') do (
      echo %%i:
      if %%i LSS E (
        echo Sorry, no USB Flash Drive available.
        pause
        EXIT
      )
    )
    echo %%i:
    echo All is well.

    :FINALEND

    I'm going a little nuts over this, as I think it should be fairly simple, but DOS is so picky. LOL Thanks in advance. If it isn't possible to remove the colon, then it's time to finagle another angle to make it work.

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Is it possible to remove the colon from the drive letter
    « Reply #1 on: January 26, 2009, 04:01:31 PM »
    Use

    Prompt $P$H$H

    You will then see only the drive Letter as for the first $H will remove the \ and the second $H will remove the : ( colon )..... The $H is a backspace to delete the characters at the tail end of the default $P prompt of C:\ giving you C
    Does this help when you see just the drive letter?

    To set it back to C:\> simply add PROMPT $P$G at the end of the batch to set back to C:\>

    Dias de verano

    • Guest
    Re: Is it possible to remove the colon from the drive letter
    « Reply #2 on: January 27, 2009, 05:08:18 AM »
    Dave, I think you misunderstand the question.

    fireballs



      Apprentice

    • Code:Terminal
    • Thanked: 3
      Re: Is it possible to remove the colon from the drive letter
      « Reply #3 on: January 27, 2009, 05:29:37 AM »
      Diskpart doesn't come back with a colon with the drive letter.  Though for what you're doing this might be more efficient:

      Code: [Select]
      @echo off
      setlocal enabledelayedexpansion
      for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "Removeable"') do (
      echo USB disks are:
      if defined %%i echo %%i
      goto here)
      echo no USBs
      :here
      pause
      exit

      FB
      Next time google it.

      1963Ford

        Topic Starter


        Newbie

        Re: Is it possible to remove the colon from the drive letter
        « Reply #4 on: January 27, 2009, 06:35:40 AM »
        FB - That's exactly what I was looking for. I was going the long way and you did it the short and simple way. Thanks. ;D
        Thanks to all who posted!  :)