Automatically open pdf files when a user saved in the folder

Hi,

I just wanted to create a batch script which should act as a watch folder, whenever a pdf file is landed in a specific folder it should open automatically and if possible it should get delete on its own after 2 days exactly...

So whenever the new file is created it should open on its own to the viewer..

thanks in advance

Logesh S
Logesh SekarAsked:
Who is Participating?
 
Lasse BodilsenSystem AdministratorCommented:
This is not exactly what you where asking for but:

IF EXIST C:\TEMP\PDFbatch\*.pdf (
	CD C:\Temp\PDFBatch\
	for %%v in (*.pdf) do ( 
		"%%v"
		move "%%v" C:\TEMP\PDFbatch\Done\
		)
)
REM Delete files older than 2 days in Done folder
forfiles /p "C:\TEMP\PDFbatch\Done" /s /m *.pdf /D -2 /C "cmd /c del @PATH"

Open in new window

It looks for pdf files in C:\Temp\PDFbatch folder, and if found will open them one by one.  (the next one is not opened before the current one is closed). And when the pdf is closed, its moved to the Done folder.  The last line then deletes any pdf file in the Done folder, that is more than 2 days old.

you could set this up in task scheduler to run every 5 min to check for new files.

Note: this should run on the User computers Task scheduler.
0
 
Logesh SekarAuthor Commented:
Thanks Lasse Bodilsen, I tried it but it is not working properly...:(
0
 
Lasse BodilsenSystem AdministratorCommented:
How is it not working?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Logesh SekarAuthor Commented:
I saved your script command as batch script and tried to open and check, but it is not working.. I also tried with task scheduler. even in thatit is not working...tell me in any other way how it should work out...
0
 
Lasse BodilsenSystem AdministratorCommented:
This is how it works:

IF EXIST C:\TEMP\PDFbatch\*.pdf
Check for *.pdf files in the the folder C:\Temp\PDFbatch, and if found proceed to the code in ( )

CD C:\Temp\PDFBatch\
Change directory to the folder  C:\TEMP\PDFbatch

for %%v in (*.pdf) do
For all pdf files in the current folder do the code in ( )

"%%v"
Run the pdf file, if the system is setup to auto open pdf files in acrobat, then that should launch.

move "%%v" C:\TEMP\PDFbatch\Done\
Move the pdf file from the current folder to C:\TEMP\PDFbatch\Done

forfiles /p "C:\TEMP\PDFbatch\Done" /s /m *.pdf /D -2 /C "cmd /c del @PATH"
For all pdf files in C:\TEMP\PDFbatch\Done that is more than 2 days old, run the command "cmd /c del @PATH", to delete the file.

So in short.

  1. Make sure you have a folder on C:\ that is named Temp, and in this temp folder, create a folder called PDFbatch, OR change the script to the folder in which you store your pdf files.
  2. in the PDFbatch folder create a folder named Done
  3. Copy some PDF files to the folder C:\Temp\PDFbatch
  4. Run the script.

if you can elaborate on what is not working, eg. if the pdf is not opening or the files is not moved/deleted, then please explain.
0
 
Lasse BodilsenSystem AdministratorCommented:
This is a testet solution that work.  if the OP can elaborate on how it is not working for him, i will gladly help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.