New
#1
Bat script to select a folder and update the path in a bat file
How do I combine this scripts? i want the highlighted folder path to been passed in to the script that's been generated (rensa_datafiler.bat)
Its begins with you select a folder:
@echo off
Title Folder Selection
echo( Select folder . . .
call:FolderSelection "%SourcePath%", SourcePath, "Select Folder"
echo( : "%SourcePath%"
pause
EXIT
Rem ---------------------------------------------------------------------------------------------------------
:FolderSelection <SelectedPath> <folder> <Description>
SetLocal & set "folder=%~1"
set "dialog=powershell -sta "Add-Type -AssemblyName System.windows.forms^
|Out-Null;$f=New-Object System.Windows.Forms.FolderBrowserDialog;$f.SelectedPath='%~1';$f.Description='%~3';^
$f.ShowNewFolderButton=$false;$f.ShowDialog();$f.SelectedPath""
for /F "delims=" %%I in ('%dialog%') do set "res=%%I"
EndLocal & (if "%res%" EQU "" (set "%2=%folder%") else (set "%2=%res%"))
exit/B 0
Rem ---------------------------------------------------------------------------------------------------------
And the other script thats replacing the text:
@echo off &setlocal
set "search=SoekVaeg"
set "replace=test"
set "textfile=template.bat"
set "newfile=rensa_datafiler.bat"
(for /f "delims=" %%i in ('findstr /n "^" "%textfile%"') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
echo(!line!
endlocal
))>"%newfile%"
type "%newfile%"
Thanks in advance