Jump to content

Creating Drag and Drop Batch File


Recommended Posts

Hi all!

I'm having trouble finding a way to create a batch file that will create pre-named folders within a folder that is dragged and dropped onto that batch file.

So my batch file currently looks like:

md New1
md "New 2"
md "New 3"\"New 4"

and I'm wondering if there is some way to create those folders in a folder that I can drag and drop onto the file.

Thanks!

Link to comment
Share on other sites


The action of drag n' drop something over a .cmd file (batch file) is passed as first parameter to the batch, which is "%1".

So, create a batch file as follows:
 

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
ECHO %1
ECHO %~1
ECHO %~d1
ECHO %~dp1
ECHO %~dpn1
ECHO %~dpnx1
ECHO %~z1
PAUSE

to have an idea of what you can get by dropping on the cmd file a directory.

As the usual recommendation, using directory or filenames including spaces is not particularly smart because there is the need to put them into double quotes (and remove quotes when needed), BTW out of the three lines you posted one is wrong.

jaclaz
 

Link to comment
Share on other sites

VBS Drag And Drop Function

'-> Checks To Make Sure Only 1 Files Is Process
 If WScript.Arguments.Count = 0 Then
  MsgBox "You Must Drag And Drop One File Onto This Script.",4128, _
  "Error No Drag And Drop performed"
 ElseIf WScript.Arguments.Count = 1 Then 
  MsgBox WScript.Arguments.Item(0),4128, "Drag Drop Demo"
 ElseIf WScript.Arguments.Count > 1 Then
  MsgBox "Drag And Drop To Many Files, This Script Is Only For One File To Be Drag And Drop Onto " & _
  "This Script",4128,"Error To Many Files"
 End If 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...