Unable to use dateTime stamp in log file name
Hi Team,
I have made SFTP connection in file named "File_Put.txt" which is working fine
I have made a bat file named "Transfer.bat" in which I am scanning each folder of source for .txt file and transfer the files to the destination folder (source and destination folder names are exactly same)
My Transfer.bat contains the following code :
FOR /R "C:\source\" %%G IN (*.txt) DO (
FOR /F %%i in ("%%G") do (
set dest_path=%%~pi
set dest_path=!dest_path:\=,!
FOR %%i in (!dest_path!) do (
echo %%i
set dest_folder=%%i
)
)
"C:\Program Files (x86)\WinSCP\winscp.exe" /ini=nul /log='C:\WinSCPScript\DateWiseTest\File_Put_!M!D!Y.log' /script=C:\WinSCPScript\DateWiseTest\File_Put.txt /parameter // %%G /!dest_folder!/
)
exit /b 0
so in the above script scan all folders under "source" folder and it is sending two parameters to "File_Put.txt"
1. %%G :- the current txt file name.
2. dest_folder :- folder name contains the txt file (source and destination folder are same for each file)
and my "File_Put.txt" is just making the SFTP connection to server and sending the file to destination folder as shown below :
open sftp://"*****":"****"*****
option transfer binary
put -nopermissions -nopreservetime %1% %2%
close
exit
where %1% and %2% are the parameters passed from "Transfer.bat".
connection details are hidden but are working fine at my end.
Now the problem is that if you observe the below line in the "Transfer.bat" :
"C:\Program Files (x86)\WinSCP\winscp.exe" /ini=nul /log='C:\WinSCPScript\DateWiseTest\File_Put_!M!D!Y.log' /script=C:\WinSCPScript\DateWiseTest\File_Put.txt /parameter // %%G /!dest_folder!/
in the bold area if I name my log file as "File_Put.log" then it runs fine but when I want to apply DateTime stamps to it as already done like "File_Put_!M!D!Y.log" then it is not running it throws error as attached.
I am very sure that it is taking wrong parameters to File_Put.txt which throws exception.
Please help me to resolve this issue as my target is to generate session log file date wise daily.
Regards,
Ashish Singh Atwal
I have made SFTP connection in file named "File_Put.txt" which is working fine
I have made a bat file named "Transfer.bat" in which I am scanning each folder of source for .txt file and transfer the files to the destination folder (source and destination folder names are exactly same)
My Transfer.bat contains the following code :
FOR /R "C:\source\" %%G IN (*.txt) DO (
FOR /F %%i in ("%%G") do (
set dest_path=%%~pi
set dest_path=!dest_path:\=,!
FOR %%i in (!dest_path!) do (
echo %%i
set dest_folder=%%i
)
)
"C:\Program Files (x86)\WinSCP\winscp.exe" /ini=nul /log='C:\WinSCPScript\DateWiseTest\File_Put_!M!D!Y.log' /script=C:\WinSCPScript\DateWiseTest\File_Put.txt /parameter // %%G /!dest_folder!/
)
exit /b 0
so in the above script scan all folders under "source" folder and it is sending two parameters to "File_Put.txt"
1. %%G :- the current txt file name.
2. dest_folder :- folder name contains the txt file (source and destination folder are same for each file)
and my "File_Put.txt" is just making the SFTP connection to server and sending the file to destination folder as shown below :
open sftp://"*****":"****"*****
option transfer binary
put -nopermissions -nopreservetime %1% %2%
close
exit
where %1% and %2% are the parameters passed from "Transfer.bat".
connection details are hidden but are working fine at my end.
Now the problem is that if you observe the below line in the "Transfer.bat" :
"C:\Program Files (x86)\WinSCP\winscp.exe" /ini=nul /log='C:\WinSCPScript\DateWiseTest\File_Put_!M!D!Y.log' /script=C:\WinSCPScript\DateWiseTest\File_Put.txt /parameter // %%G /!dest_folder!/
in the bold area if I name my log file as "File_Put.log" then it runs fine but when I want to apply DateTime stamps to it as already done like "File_Put_!M!D!Y.log" then it is not running it throws error as attached.
I am very sure that it is taking wrong parameters to File_Put.txt which throws exception.
Please help me to resolve this issue as my target is to generate session log file date wise daily.
Regards,
Ashish Singh Atwal