Hi all,
I'm planning to essemble a script to get "play a sound when any download finished", that is:
monitor files extension changing in a folder - this folder is a download target folder (both as temporary file and target folder), when a download begins, a new temp file, say ABC.ZIP.FDMDOWNLOAD will be added to here, when download done, it will be renamed to ABC.ZIP
My intention is to detect this kind of renaming ONLY. And forget about this "FDMDOWNLOAD", it doesn't need to be detail specific - any file renaming in this folder is good enough - will cause a song play.
And: any file added to this folder should not trigger alarm.
No subfolder needs to be monitored.
I was thinking about scanning the whole folder again and again. Then I searched about "FindFirstChangeNotificationW", then "ReadDirectoryChangesW". I have to admit this windows API thing is over me.
Could anybody please help?
watch a folder ONLY for file renaming Topic is solved
Re: watch a folder ONLY for file renaming Topic is solved
This will give you some ideas
Once the file that ends with ABC.ZIP.FDMDOWNLOAD in X:\ disappear for whatever reason(including renaming which is also like moving it or deleting it),a sound will play and break the loop
Code: Select all
Loop
{
Sleep,1000
IfNotExist,X:\*.ABC.ZIP.FDMDOWNLOAD
{
SoundPlay,C:\Windows\media\Windows Logon.wav,wait
Break
}
}
Re: watch a folder ONLY for file renaming
You can take a look at WatchDirectory by HotKeyIt
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: watch a folder ONLY for file renaming
Thank you, sir. That's neat and simple. Although I sometimes have more than one download task simutaneously, I just need an alert when all of them done. So, great tip!
Re: watch a folder ONLY for file renaming
You might want to check out the updated version of WatchDirectory called WatchFolder by just me.
Re: watch a folder ONLY for file renaming
Thanks boiler. I forgot that one, I even use it in one of my script. I'm gettin' old.
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: watch a folder ONLY for file renaming
Hi,
what I can imagine:
a) you remember per file: file size, creation-time-stamp and name
b) as soon as name changes and file size and creation-time-stamp stays the same values then
c) you know that somebody changed the name of a certain file
the probability, that you have files with same file size and creation-time is against zero.
If there is a file, for which you havent remembered (stored) file size and creation time, then it is a new file and not a file-name-change
So that should work (from a logicial perspective)
J.B.
what I can imagine:
a) you remember per file: file size, creation-time-stamp and name
b) as soon as name changes and file size and creation-time-stamp stays the same values then
c) you know that somebody changed the name of a certain file
the probability, that you have files with same file size and creation-time is against zero.
If there is a file, for which you havent remembered (stored) file size and creation time, then it is a new file and not a file-name-change
So that should work (from a logicial perspective)
J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
Re: watch a folder ONLY for file renaming
Thanks guys.
I'll keep those powerful and complicated for later study.
My try based on @vsub's enlightenment:
I'll keep those powerful and complicated for later study.
My try based on @vsub's enlightenment:
Code: Select all
#Persistent
Loop
{
Sleep,1000
If FileExist("H:\*.fdmdownload")
{
laststatus := 1
Continue
}
If ( !FileExist("H:\*.fdmdownload") and laststatus=1 )
{
;SoundPlay,C:\Windows\media\Windows Logon.wav,wait
;yeah, my soundplay stops working,too, no idea.
vPath := "d:\alert7.wav"
vRet := DllCall("winmm\PlaySound" (A_IsUnicode?"W":"A"), Str,vPath, Ptr,0, UInt,0x20000)
laststatus := 0
Continue
}
}
Who is online
Users browsing this forum: Descolada, roeleboele and 394 guests