29 April 2016

3 Ways to Format USB Pen Drive Using Command Prompt

2 comments
Formatting USB pen drive is one of the easiest thing and almost anyone can do it. You just need to insert the pen drive then, go to My Computer, right-click on pen drive icon and click "Format" option. Finally hit "Start" button followed by OK and that's it. But did you ever tried to format it with Command Prompt.

Format Pen Drive Using CMD

Well this can be helpful in many ways. For example, sometimes your USB pen drive may not format via direct method or it may occupy unnecessary space even after formatting. Such problems can be solved by formatting it with Windows Command Prompt. In this tutorial, I will guide you how to format it in right way.

1. Use format command


Out of hundreds of Command Prompt commands, one of them is "Format". As name itself speak, this command let you erase/delete complete data of any drive. For example, it can erase your D drive. The basic syntax is - "format [drive address here]"

For example, "format D:\". You can also add few parameter in this command. One of the most used parameter is "/q". This performs a quick format. Normally If it takes 10 minutes, adding this parameter will increase the speed by 70% least. Here is the example of this parameter -

format /q H:
Now I just hope that you've little bit understanding about this command. To format your USB pen drive, follow these steps by step instructions -
  1. First of all, find out the drive name of your pen drive. You can find it from my computer window. (See below picture)

    Find Drive Name

  2. Now go to start menu and open Command Prompt (Search for cmd.exe).
  3. Type this code and press ENTER button -
    format /q H:
    Don't forget to replace "H" with your own drive name.

    Format Command
  4. Now you've to press ENTER button two more times when it will show "Insert new disk for drive H:\" and "Volume label" message. After this, wait for few seconds or minute(s) and when it's done, it will show the success message.
In this way, you can easily delete all your USB pen drive files using Command Prompt. Just open it and you will find nothing. You can also use this trick to remove shortcut virus from your pen drive. (It really worked for me)

Also check: Change text and background color of Command Prompt


2. Create batch program


Another way of formatting the pen drive is by using batch program. Batch is a scripting language which works in Windows, DOS and OS 2 platform and can be programmed in Notepad or simply in Windows Command Prompt Shell. It consist of simple commands to be executed by command line interpreter.

Using this program, you don't need to do any programming. Just type the drive name and that's it. Once created, you can use it any number of time. As this program is a file, so you can also share it with your friends or other colleagues. Now to create it, first copy this code and then proceed with below steps.

@echo off
title Pen drive
echo Welcome to the program
Set /p input=Please enter the drive name of your pen drive:
echo Press any key to continue..!
pause>nul
format /q %input%:
echo Your pen drive has been successful formatted.
echo Press any key to exit the program!
pause>nul
exit
  1. Open Notepad.
  2. Now paste the above code inside it.
  3. To save it, click on "File > Save as" option.
  4. Now choose the location where you want to save this program and type its file name (e.g., "batchprogram.bat")

    Make sure to add ".bat" at the end of file name. This is the file extension of batch programs and without it, your program will not work.
  5. At last, hit save button and you've successfully created it.
Now whenever you want to format your pen drive, open this program and just type the drive name.

Also read: How to create a simple calculator in batch program

3. Use rmdir command


Apart from format command, there is another command named as "rmdir" (stands for remove directory). This works in the same manner as deleting works. You can use this command to delete the files and folders of your pen drive. To under the difference between rmdir and format command, you've to know the basic difference between deleting and formatting.

In deleting, you have to manually delete each file or folder while formatting deletes everything at once. Both work is to erase the data. On the other hand, deleting will still occupy the free space of deleted files and it can be recovered but this was opposite in case of formatting. To use this rmdir command, type this code -

rmdir /q /s H:\
rmdir command

Here "/s" parameter is used to remove a directory tree whereas "/q" parameter is a quite mode (Using it, Command Prompt will not ask for permission). You can find more about these rmdir and format command by executing "rmdir /?" and "format /?" code respectively. I had tried my best to make this tutorial simple but still If you've any problem, I would like to hear it in comment box. Stay tuned for more interesting tutorials.

2 comments:

  1. Bro,
    Is there any other option or way to format PENDRIVE
    These Options r not working with my PD

    ReplyDelete
  2. how to format write protected pendrive.

    ReplyDelete