File Path Auto Copy

This is how to make a Batch script that will automatically determine the file path of an item or directory and then save it to the clipboard when you drag and drop said item on the batch script desktop icon.

  1. Create a batch file named anything.bat in a text editor and save it to the desktop.
  2. Copy the following text.

          @echo off
          REM Simple, but highly useful; this sends the path of whatever you drag and drop on it. to the clipboard
          :: I like to keep it on the Windows Desktop to quickly copy the path of a file.
          set filename=%1
          for %%F in (“%filename%”) do set dirname=%%~dpF
          for %%F in (“%dirname%”) do set dirname=%%~dpF
          echo %dirname% | CLIP

To use:

  1. Just drag ‘n’ drop a file onto the desktop icon
  2. and then paste the file path text where you want it.