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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ACT

From novice to tech pro — start learning today.