我遇到了以下问题:
我需要制作一些东西来检查文件是否已添加到特定文件夹,如果需要打印此文件。我听说Windows可能内置了类似的内容吗?
*Program constantly checks whether a file has been added*
File has been added
File gets printed immediately
我找到了解决方案,但您需要为它们付费。
更新
"Code supplied by Vik"
:start
set SECONDS=60
SET FILENAME=*.jpg
IF EXIST %FILENAME% MSPAINT /p %FILENAME%
choice /C a /T %SECONDS% /D a
DEL /Q %FILENAME%
goto :start
"Edits: COPY *.JPG file to a different folder (E.G. ImageHistory)"
"Edits: DELETE local *.JPG file leaving the monitor folder empty"
欢迎任何提示或帮助!
答案 0 :(得分:1)
在后台运行VB.Net并使用FileSystemWatcher获取该文件夹中每个更改的事件。收到事件后,检查文件/操作并使用可以打印它们的任何应用程序打印文件。批处理文件可能无法在此处运行。
答案 1 :(得分:1)
此批处理文件将检查文件printme.jpg是否每60秒存在一次。如果存在,它将使用内置的MSPAINT程序进行打印。随意配置SECONDS和FILENAME以适应您的环境。
:start
set SECONDS=60
SET FILENAME=printme.jpg
IF EXIST %FILENAME% MSPAINT /p %FILENAME%
choice /C a /T %SECONDS% /D a
goto :start
您可能想要制作的其他模式:
PING 1.1.1.1 -n 1 -w 60000 >NUL
DEL /Q %FILENAME%
编辑(下方):添加了多文件,移动和删除功能
set SECONDS=20
set FILEFOLDER=C:\dropfolder
set TEMPFOLDER=%FILEFOLDER%\TEMPFOLDER
set FILEWILDCARD=*.jpg
if not exist "%FILEFOLDER%" ECHO %FILEFOLDER% NOT FOUND ... CTRL-C TO EXIT && PAUSE
if not exist "%TEMPFOLDER%" ECHO %TEMPFOLDER% NOT FOUND ... CTRL-C TO EXIT && PAUSE
:start
cd "%FILEFOLDER%"
dir /b "%FILEWILDCARD%" > filelist.txt
for %%A in (filelist.txt) do if not %%~zA==0 goto printfiles
choice /C a /T %SECONDS% /D a
goto :start
:printfiles
echo FILE(s) FOUND!
del /q "%TEMPFOLDER%\%FILEWILDCARD%"
move "%FILEWILDCARD%" "%TEMPFOLDER%"
cd "%TEMPFOLDER%"
for %%A in ("%FILEWILDCARD%") do MSPAINT /p "%%A"
goto :start