help me program .bat when drag&drop any file it show name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sonyman
Posts: 10
Joined: 25 Oct 2014 01:01

help me program .bat when drag&drop any file it show name

#1 Post by sonyman » 29 Mar 2015 03:24

eg:
i have a file : abcxyz.apk
i want create program test.bat
when drag and drop file abcxyz.apk in test.bat
it show name file abcxyz
(file name is random)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: help me program .bat when drag&drop any file it show nam

#2 Post by ShadowThief » 29 Mar 2015 04:03

When you drag a file onto a batch script, the full path, including the file name, is stored in %1. You can get the file name without the extension by using %~n1.

sonyman
Posts: 10
Joined: 25 Oct 2014 01:01

Re: help me program .bat when drag&drop any file it show nam

#3 Post by sonyman » 30 Mar 2015 21:12

ShadowThief wrote:When you drag a file onto a batch script, the full path, including the file name, is stored in %1. You can get the file name without the extension by using %~n1.

thank!!
but if i want click run test.bat to it's show file name then how to do ?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: help me program .bat when drag&drop any file it show nam

#4 Post by ShadowThief » 31 Mar 2015 01:29

The path and filename of the script itself are stored in %0. Again, you can get just the file name with %~n0.

sonyman
Posts: 10
Joined: 25 Oct 2014 01:01

Re: help me program .bat when drag&drop any file it show nam

#5 Post by sonyman » 31 Mar 2015 02:17

now i want click to run not drag and drop file
picture :
http://www.upsieutoc.com/image/pF1Y
so how to do ?
-------------------------------------
drag drop file i have done
@echo off
title test
echo show file name
echo.
set name=%~n1
echo -------------
echo file name : %name%
echo folder path : %1
echo _____________
echo %~n1 >> litleboy.txt
echo %1 >> litleboy.txt
pause

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: help me program .bat when drag&drop any file it show nam

#6 Post by Squashman » 31 Mar 2015 07:31

Are you saying that you want the user to input the file name if the batch file is double clicked?

Post Reply