0

I recognize that the issue here is more likely to do with the bat file itself rather than the right click -> Send To -> shortcut to bat file so here goes...

I wanted to implement the bat file code found here

The idea being that the user selects a bunch of files in a folder, right clicks, and can send the files to the bat file to create a list of file names.

So I created the bat file, create a shortcut to the bat file. placed the shortcut into my send to folder and the Send To option to the bat file appears as expected.

However, when I select a bunch of files (or even just one) and right click - Send To - bat file, windows explorer will blink as if doing something but no txt file generates. See below for my exact file contents:

@echo off
set "OutputFile=C:\Users\Paul\Desktop\FileNames.txt"
del "%OutputFile%" 2>nul
:NextFileName
if not "%~1" == "" (
    echo %~nx1>>"%OutputFile%"
    shift
    goto NextFileName
)
if exist "%OutputFile%" (
    %SystemRoot%\System32\sort.exe "%OutputFile%" /O "%OutputFile%"
)

So what is wrong?

Sweepster
  • 1,747
  • 4
  • 25
  • 59

1 Answers1

0

Don't use %~1 use %1 as if I am not wrong %~1-9 is meant for functions and %1-9 for cmd paramaters.

vlOd
  • 17
  • 6
  • you *are* wrong. The tilde just removes surrounding quotes (if there are any; no effect if there are none) It always references parameters (to a batch file or to a "function" (I personally prefer the term "subroutine") – Stephan Jan 05 '21 at 16:51