Solved Get file when downloaded

December 6, 2011 at 07:46:18
Specs: Windows 7, Intel Celeron Duo T3300 @ 2GHz 64MB L2
Hello forum,
Can someone help me with this script; imagine I have D:\Downloads. How do I open a file with a batchfile when it gets in there? Is it possible to do this by creating directory lists like:
dir /b>D:\project\dirlist.txt
?

See More: Get file when downloaded

Report •

✔ Best Answer
December 15, 2011 at 09:03:58
Oh, there are other ways, mostly involving one of the other scripting languages (VBScript or PowerShell). VBScript would use WMI, which would poll the directory in question. PowerShell could use .NET's FIleSystemWatcher class to watch a directory. Either are more hassle than having an add-on run your script.

How To Ask Questions The Smart Way



#1
December 6, 2011 at 11:41:29
If you want to run/open a file from a directory use;
START D:\Downloads\file.txt

If by "when it gets there" you mean, when the file has downloaded, auto run it.
You'll need a loop to keep checking if the file is there like;

@ECHO OFF
:LOOP
IF EXIST D:\Downloads\file.txt Goto :OPEN
Goto :LOOP
:OPEN
START D:\Downloads\file.txt

But you will be left with an empty window on your screen.
Hope this helps.


Report •

#2
December 6, 2011 at 11:47:06
Ok, but there are many other files in there, and imagine I don't know the filename?

Report •

#3
December 6, 2011 at 14:53:35
You kinda have to know what you want to run. Otherwise why are you trying to start a program/file without knowing what it is?
I don't quite understand what you want to do.

Explain exactly what you want the batch file to do, step by step as best you can.


Report •

Related Solutions

#4
December 6, 2011 at 22:40:31
So I have a folder, in there I put all my downloads. And if I download, something new comes in that folder. But I have to wait untill the download is finished, untill that time a *.part file will grow. After that, the *.part file will disappear and rewritten to the *.zip file I downloaded. The download is completed.
The main concept was a batchfile that checks the folder realtime, if anything new comes in there and runs the new file if its GREATER than 0 bytes (thus when its *.part file disappears).

Maybe something like:

:top
cd D:
cd Downloads
dir /b > d:\dirlist.txt
:search
dir /b > d:\dirlist2.txt
REM script goes here; if anything new comes in the folder it'll be compared
íf %newfile% gtr 0 (
del d:\dirlist.txt
ren "d:\dirlist2.txt" "d:\dirlist.txt"
REM that's to get the new list
start %newfile%
goto search


Report •

#5
December 7, 2011 at 08:03:40
Now I have something like:
dir /b > %temp%\files\dirlist.txt
dir /b > temp%\files\dirlist.txt
fc temp%\files\dirlist.txt temp%\files\dirlist.txt > %temp%\files\change.txt

what comes next?


Report •

#6
December 14, 2011 at 03:35:25
BUMP please help?

how do i make dos monitor a folder and open a new incoming file?


Report •

#7
December 14, 2011 at 07:53:35
I am still waitin' for answer lol

Report •

#8
December 15, 2011 at 06:04:56
I have an add-on for Firefox, called Download Statusbar. In this add-on is an option for a "manual virus scan." Install the add-on, and point the "virus scan" to your script.

How To Ask Questions The Smart Way


Report •

#9
December 15, 2011 at 08:36:09
I appreciate your help. I think there is indeed no other way.

Report •

#10
December 15, 2011 at 09:03:58
✔ Best Answer
Oh, there are other ways, mostly involving one of the other scripting languages (VBScript or PowerShell). VBScript would use WMI, which would poll the directory in question. PowerShell could use .NET's FIleSystemWatcher class to watch a directory. Either are more hassle than having an add-on run your script.

How To Ask Questions The Smart Way


Report •

Ask Question