Page 1 of 1

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

Posted: 29 Mar 2015 03:24
by sonyman
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)

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

Posted: 29 Mar 2015 04:03
by ShadowThief
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.

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

Posted: 30 Mar 2015 21:12
by sonyman
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 ?

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

Posted: 31 Mar 2015 01:29
by ShadowThief
The path and filename of the script itself are stored in %0. Again, you can get just the file name with %~n0.

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

Posted: 31 Mar 2015 02:17
by sonyman
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

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

Posted: 31 Mar 2015 07:31
by Squashman
Are you saying that you want the user to input the file name if the batch file is double clicked?