I have a batch file that moves a downloaded file after a download in Axway Secure Client. My batch file moves the file from the download destination folder to a "hot folder" (monitored by other application) where it is immediately processed. The batch file also echo's various output into a log file depending on successful or failed move. The move works fine, but the echoed text inserts an addition \ for every path delimiter, so that the destination in the log file is:
d:\\foldername\\foldername rather than d:\foldername\foldername
This folder name is obtained from the same %variable as the destination in the move operation, which works, so I'm not sure why it shows double \ in the log. Here is an example of the log entry, and below that, the actual batch file:
Log entry:
2016/01/25, 10:12:14.69, Moving XXXXXXXXXXXXXXXXXXXXXXXXXXXX.dat to D:\\ftpdata\\ENTKMONITOR, successful
(Name removed because this is confidential banking data)
Batch file:
set Year=%date:~10,4%
set Month=%date:~4,2%
set Day=%date:~7,2%
set Today=%Year%/%Month%/%Day%
move %1 %2 && (echo %Today%, %time%, Moving %1 to %2, successful >> \\fnb.cfbi.local\data\Apps\FTP\ftpdl\FTPAXWAYMOVE\movefile.bat.log) || (echo %Today%, %time%, Moving %1 to %2, failed >> \\fnb.cfbi.local\data\Apps\FTP\ftpdl\FTPAXWAYMOVE\movefile.bat.log)
Any help would be GREATLY appreciated!
TIA
CR
Echoing paths to log file shows \\ in path names instead of \
Moderator: DosItHelp
Re: Echoing paths to log file shows \\ in path names instead of \
What program is executing your batch file? The only way the slashes would be getting doubled is if they were passed to the batch file that way.
Re: Echoing paths to log file shows \\ in path names instead of \
Squashman wrote:What program is executing your batch file? The only way the slashes would be getting doubled is if they were passed to the batch file that way.
It's being launched by the Axway Secure Client software. The command to do so is:
x:\BatchFiles\movefile.bat %f d:\ftpdata\entkmonitor
Where %f is the current filename, and d:\ftpdata\entkmonitor is the destination.
They are received by the batch file as %1 and %2. When moving the files, in the batch file, as you can see, it's simply
move %1 %2
Here's %2 obviously only has single \'s because the moves are successful. If %2 contained \\ between foldernames, it would fail. I'm using the same thing (%2) in echoing to the log file.
As far as functionality of the batch file, I'm not concerned, as it's working correctly in the move. It's really just bugging the hell out of me in the log file.
Thanks.
Re: Echoing paths to log file shows \\ in path names instead of \
Squashman wrote:What program is executing your batch file? The only way the slashes would be getting doubled is if they were passed to the batch file that way.
Maybe disregard my previous reply. I just did a few tests...using \, \\, \\\, and /\, as folder delimiters... seems those all work just fine with a windows/dos "move" *sigh*
Re: Echoing paths to log file shows \\ in path names instead of \
As mentioned above, it's definitely coming from the initial command line that the batch is launched from. Most, if not all, file operations don't care if you have extra slashes in the path, which is why the move works. If the extra slashes in the log cause you a problem, you can try expanding the offending %2s to %~f2. I tested it briefly and it seems to reduce any number of slashes down to one, but I would personally leave things as they are.
Re: Echoing paths to log file shows \\ in path names instead of \
All you have to do is echo %1 and %2 at the top of the batch file which will prove that your thrid party program is causing the extra slashes.
Re: Echoing paths to log file shows \\ in path names instead of \
Squashman wrote:All you have to do is echo %1 and %2 at the top of the batch file which will prove that your third party program is causing the extra slashes.
+1