The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

zmagic (1) [Avatar] Offline
Hello Everyone,
I am a newb and i need help regarding running batch file which i want to run inside the selected folder.

The batch file is simple and it does only merger of text files available inside the folder.

Below are the code of batch script and following are the codes for browse to folder codes taken from this forum. Please help to set both the code so on click it will allow me to search the folder and once click it will run the batch script.

@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"

set name=%dd%%mm%%yyyy:~2%Q

set "flag="
for %%a in (*.txt) do (
if not defined flag (
copy "%%a" "%name%" >nul
set flag=1
) else (
more +1 "%%a" >>"%name%"

Open Folder Dialog (Posted in this forum : Calling FolderBrowserDialog from a PowerShell script )
# Show an Open Folder Dialog and return the directory selected by the user.
function Read-FolderBrowserDialog([string]$Message, [string]$InitialDirectory)
$app = New-Object -ComObject Shell.Application
$folder = $app.BrowseForFolder(0, $Message, 0, $InitialDirectory)
if ($folder) { return $folder.Self.Path } else { return '' }

Thanks in advance.