1.

Solve : batch file to upload PDF to dev server?

Answer»

Hi all,
New to batch files so I've got no clue where to start. After researching for hours, I've decided to finally make a post.

I need to create a batch file that uploads a pdf file to a development server. And from there, I need another batch file that will upload to our intranet server. Basically, we can't give access to the intranet server to the person who saves the original pdf but need for the pdf to be updated daily, or even better updated by a trigger when the original machine uploads to the dev server.

Help is very much appreciated.

So this is what a friend of mine WROTE for me but there seems to be something going on with the oldfiledate.txt. It's created initially and then it writes to the Y;\ but after its been created, it doesn't update anymore. The oldfiledate.txt also doesn't update the time stamp in the date MODIFIED column in Explorer, which is suspect is why the files aren't getting copied with the exception of the initial transfer.

Suggestions?

Code: [SELECT]
REM @echo off
REM **** This was written by Me for You.
REM **** This cost 2 beers. The tab is now at 8 beers. :-)

REM **** This is a batch file that can be run every minute on the server that the
REM **** end user is copying to.

REM **** Get the current file date of the file.
FOR /F "tokens=1,2,3,4,5,6 delims=/: " %%d in ('dir/n SUBLIST.pdf^|findstr /I /C:"sublist"') do set

currentfiledate=%%d%%e%%f%%g%%h%%i

REM **** Store the current date time stamp into a file.
ECHO %date% %time% > currentfiledate.txt

REM **** Uncomment the REM below here if you need to debug.
REM echo %currentfiledate%

REM **** Make sure the old file is there. If it's not, then we know we need to copy it right away.
IF NOT EXIST oldfiledate.txt GOTO nomatch

REM **** Read in the previous date time stamp of the file.
FOR /F "tokens=* " %%a in (oldfiledate.txt) do set oldfiledate=%%a

REM **** Uncomment the REM below here if you need to debug.
REM echo %oldfiledate%

REM **** Compare the current file date with a previously stored file date.
IF %oldfiledate% == %currentfiledate% (goto match) ELSE goto nomatch

REM **** Done with CHECKING. To avoid running the commands below, good programming practice
REM **** dictates we should put in a goto to the end of the program
GOTO finish

REM **** Don't do anything. The file is the same. Skip down to the end of the program.
:match
GOTO finish

REM **** Do something as the file date has changed. Once done, skip down to the end of the program.
:nomatch
REM **** Update the oldfiledate.txt so it contains the new file date/timestamp for comparison the
REM **** next time around.
COPY currentfiledate.txt oldfiledate.txt
REM **** Copy the file from server to server.
COPY /Y C:\Inetpub\wwwroot\Spirit\Forms\HR\sublist.pdf Y:\intranet\Forms\HR\sublist.pdf
GOTO finish

REM **** End of program
:finish



Discussion

No Comment Found