Hi all

I have been working on a batch file for exporting wireless profiles. The file i created yesterday worked great, however as normal I left work and then immediately thought of a flaw with it. I have been trying to fix the flaw this morning though and have come up against an issue. My menu options don't seem to be working. I have butchered another script i have that works to create this but tbh i don't understand enough about batch files to work out what is wrong.

Working export script (before my changes):
Code:
set wlanfld="C:\WirelessProfiles"
if not exist %wlanfld% md %wlanfld%
echo off
netsh wlan export profile folder=%wlanfld% key=clear
setlocal enabledelayedexpansion
for /r %wlanfld% %%a in (*.xml) do (
set oldName=%%~xna
set newName=!oldName:~28!
ren "%%a" "!newName!"
)
Working Import Menu file:

Code:
@ECHO OFF
:listwlan
SET index=1

SETLOCAL ENABLEDELAYEDEXPANSION

cls
echo.
echo 0 - No Wireless
echo.
FOR /r C:\WirelessProfiles\ %%f IN (*.xml) DO (
   SET file!index!=%%f
   ECHO !index! - %%~nxf
   SET /A index=!index!+1
)
echo.
Set /P selection="Select Wireless Profile number: "

SET file%selection% >nul 2>&1

IF ERRORLEVEL 1 (
   echo.
   ECHO Skipping Wireless Profile Setup 
   EXIT /B 1
)
CALL :RESOLVE %%file%selection%%%

ECHO selected file name: %file_name%
netsh wlan add profile filename=%file_name%
GOTO :listwlan

:RESOLVE
SET file_name=%1
GOTO :EOF
The file i have tried to create by combining the two and other tips online:

Code:
echo off
cls
SETLOCAL ENABLEDELAYEDEXPANSION
set wlanfld="C:\WirelessProfiles"
if not exist %wlanfld% md %wlanfld%
echo off
echo Wireless Profile Export Menu
echo ============================
echo.
echo.
echo Which export routine do you want to run?
echo.
echo 1. Export All profiles
echo 2. Export certain profiles only
echo. 
set /p export="What do you want to do?: "
if %export%==1 (
netsh wlan export profile folder=%wlanfld% key=clear
setlocal enabledelayedexpansion
for /r %wlanfld% %%a in (*.xml) do (
set oldName=%%~xna
set newName=!oldName:~28!
ren "%%a" "!newName!"
) else if %export%==2 (
netsh wlan show profiles C:\temp.txt
for /f "skip=10 delims=*" %%a in (C:\temp.txt) do (
echo %%a >>C:\newfile.txt    
)
xcopy C:\newfile.txt C:\temp.txt /y
del C:\newfile.txt /f /q 
) else (
echo invalid choice - exiting
)
For a bit of background as to why I have started to edit the export file, the current export routine will always export ALL wireless profiles and then try and remove the first 28 characters from the filename. The problem with this is that if the resultant filename exists the new file is not renamed and is just left in the export folder.