I am trying to write a batch file that will copy a file from one network drive to another and rename it on the new location so the filename has the date at the end.
Below is what I have so far but this is not working. It hits problems with files that have spaces in them, sometimes returns the error 'NET is not a valid command' and does not wait until the file is finished copying before moving on to the next command.
I can also only get the date added to the begining of the file when ideally I need it at the end.
REM Fetch the file name from the command line
net use \\llsvr-bur-3330\d$ /USER:DOMAIN\username password
net use \\llsvr-bur-3333\e$ /USER:DOMAIN\username password
REM Create the date and time elements.
For /f "tokens=1-7 delims=:/-, " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do (
For /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do (
REM COPY FILE AND RENAME WITH DATE AND TIME APPENDED
START /WAIT /B COPY /V %NAME% %NEW_FILE%
Could someone possibly give me some help sorting this out please? Sorry if this seems like a bit of a hopeless attempt, its my first attempt at windows batch files! Thanks in advance for any help.