Ok, just test this for now and tell me if there are any problems.
Code:
echo off
setlocal enabledelayedexpansion
cls
echo user me@company.com> ftpcmd.dat
echo password>> ftpcmd.dat
echo mls . 1.tmp>> ftpcmd.dat
echo y >> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.company.com
del ftpcmd.dat
type mls.tmp | more +2 > trim.tmp
findstr /N "^" trim.tmp > dirs.tmp
:invalid
set count=0
Echo Directories:
Echo.
for /f %%a in (dirs.tmp) do (
set /a count+=1
Echo !count!. %%a
)
Echo.
set /p "choice=Enter directory number: "
if "%choice%" equ "" (Echo Invalid Choice... &pause&cls&goto :invalid)
if %choice% lss "%count%" (Echo Invalid Choice... &pause&cls&goto :invalid)
if %choice% lss 0 (Echo Invalid Choice... &pause&cls&goto :invalid)
set count=0
set dir=null_value
for /f %%a in (dirs.tmp) do (
set /a count+=1
if !count!==!choice! set dir=%%a
)
cls
if "%dir%"=="null_value" (
Echo Error: direcotry finding
pause&Exit)
cls
Echo Selected %dir%
pause
cls
echo user me@company.com> ftpcmd.dat
echo password>> ftpcmd.dat
echo cd %dir%>> ftpcmd.dat
echo mls . mls.tmp>> ftpcmd.dat
echo y >> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.company.com
del ftpcmd.dat
findstr ".htm" mls.tmp > trim.tmp
findstr /N "^" trim.tmp > files.tmp
:invalid
set count=0
Echo files:
Echo.
for /f %%a in (files.tmp) do (
set /a count+=1
Echo !count!. %%a
)
Echo.
set /p "choice=Enter file number: "
if "%choice%" equ "" (Echo Invalid Choice... &pause&cls&goto :invalid)
if %choice% lss "%count%" (Echo Invalid Choice... &pause&cls&goto :invalid)
if %choice% lss 0 (Echo Invalid Choice... &pause&cls&goto :invalid)
set count=0
set sel=null_value
for /f %%a in (files.tmp) do (
set /a count+=1
if !count!==!choice! set sel=%%a
)
cls
if "%sel%"=="null_value" (
Echo Error: File finding finding
pause&Exit)
cls
Echo Selected %sel%
pause
cls
set new=%date:~10,4%%date:~4,2%%date:~7,2%%sel:~9%
cls
echo user me@company.com> ftpcmd.dat
echo password>> ftpcmd.dat
echo cd %dir%>> ftpcmd.dat
echo rename %sel% %new%>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.company.com
del ftpcmd.dat
del *.tmp
There could be a lot of mistakes in that, but it should work. If it doesn't work, try running it in cmd as so:
- Start CMD
- Type Cmd.exe
- Drag and drop the batch file into the cmd window to run it from that directory
This way you will get an error message telling you whats wrong. If you do get one, tell me what it is and I can try fixing it for you.
Mona