1.

Solve : script file to add date to file name?

Answer»

Hello Folks,

Have a small problem that I'm hoping I COULD get some assistance with.  I currently have a batch file which that that ftp's a .txt to a desired location. I want to rename this text file with current month in abbreviation and year  to the filename my filename is MISFTP.txt it should be rename to be something like 102.txt  i.e 102oct'17


USER user   
PASS password
CONNECT "gggggg"
ONERROR GOTO DISCONNECT
cd MISFTP
MPUT MISFTP.txt
RNFR /home/ssattu/MISFTP/MISFTP.txt
RNTO /home/ssattu/MISFTP/102.txt
LABEL DISCONNECT
CLOSE
You don't need to use the rename command.  You can name it when you use the put the command.
Code: [Select]PUT MISFTP.txt 102oct17.txtIf you are LOOKING for a way to get the month name and century into variables to use to build your FTP script, this should help you with that.
Code: [Select]echo off
setlocal EnableDelayedExpansion
set m=100
for %%m in (January February March April May JUNE JULY August September October November  December) do (
   set /A m+=1
   set month[!m:~-2!]=%%m
)
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /VALUE') do set "dt=%%a"
set cc=%dt:~2,2%
set mm=%dt:~4,2%
set monthName=!month[%mm%]!
echo Month Name: %monthName%
echo    Century: %cc%
pause



Discussion

No Comment Found