I'm very new to scripting!
Would anybody be able to help with a script that would, if you had used your internet browser to upload files from a particular folder, use a message box prompt to empty that folder?
An additional/alternative script would be a message box that prompts to delete files, after running a periodical check to see if there are any files in a particular folder.
These scripts are intended to assist with online storage of documents - to remove the chance that you are storing documents in more than one place!
Prompt to empty folder after upload
Started by
KoreMike
, May 07 2012 03:26 PM
3 replies to this topic
#1
KoreMike
Posted 07 May 2012 - 03:26 PM
#2
Posted 07 May 2012 - 04:10 PM
The first one is beyond me to do in a sophisticated way. This script checks every 5 seconds whether the upload window is open and if it is, offers to delete the folder contents.
The second request is easier. Every 10 seconds this script checks if there is anything in a given folder and if there is, offers to delete it.
The second request is easier. Every 10 seconds this script checks if there is anything in a given folder and if there is, offers to delete it.
SetTimer, UploadCheck, 5000 ;every 5 seconds
SetTimer,FolderCheck,10000 ;every 10 seconds
return
UploadCheck:
IfWinexist,UploadWindow ;Name of the window where you upload your stuff to
{
msgbox,4,,The window is open. Delete folder content?
IfMsgBox Yes
{
loop,C:\test\*.*
{
Filedelete,%A_LoopFileLongPath%
}
}
else
{
MsgBox, GREAT! PERFECT! I'll never offer my help again!
ExitApp ;delete this if you dont want the script to close after the no
}
}
return
FolderCheck:
loop,C:\test\*.*
{
msgbox,4,,Stuff found in the folder. Delete folder content?,4
IfMsgBox Yes
{
loop,C:\test\*.*
{
Filedelete,%A_LoopFileLongPath%
}
}
else
{
MsgBox, GREAT! PERFECT! I'll never offer my help again!
ExitApp ;delete this if you dont want the script to close after the no
}
}
return
Escape::
ExitApp
return
#3
KoreMike
Posted 07 May 2012 - 04:52 PM
Great thanks!
I thought the first one might be a bit complicated.
I've tried the second one and it's nearly there, but the message box appears 2 or 3 times and very quickly goes to the GREAT THANK YOU message if you don't react fast enough.
Is there a 'loop' in the code that shouldn't be there?
This is the code:
I thought the first one might be a bit complicated.
I've tried the second one and it's nearly there, but the message box appears 2 or 3 times and very quickly goes to the GREAT THANK YOU message if you don't react fast enough.
Is there a 'loop' in the code that shouldn't be there?
This is the code:
SetTimer,FolderCheck,30000 ;every 30 seconds
return
FolderCheck:
loop,%A_Desktop%\Upload to O3\*.*
{
msgbox,4,,Stuff found in the folder. Delete folder content?,4
IfMsgBox Yes
{
loop,%A_Desktop%\Upload to O3\*.*
{
FileDelete %A_Desktop%\Upload to O3\*.*
}
}
else
{
MsgBox, GREAT! PERFECT! I'll never offer my help again!
}
}
return
Escape::
ExitApp
return
#4
KoreMike
Posted 07 May 2012 - 06:06 PM
I've got it working the way I want now. I used this line for the folder check:
I think the 1 at the end was necessary to only make the check once!
I also set the timeout to 15 seconds:
Here's the full code:
FolderCheck: Loop, %A_Desktop%\Upload to O3\*.*,, 1
I think the 1 at the end was necessary to only make the check once!
I also set the timeout to 15 seconds:
msgbox,4,,Stuff found in the folder. Delete folder content?,15
Here's the full code:
SetTimer,FolderCheck,30000 ;every 30 seconds
return
FolderCheck:
Loop, %A_Desktop%\Upload to O3\*.*,, 1
{
msgbox,4,,Stuff found in the folder. Delete folder content?,15
IfMsgBox Yes
{
loop,%A_Desktop%\Upload to O3\*.*
{
FileDelete %A_Desktop%\Upload to O3\*.*
}
}
IfMsgBox No
{
MsgBox, GREAT! PERFECT! I'll never offer my help again!
}
IfMsgBox Timeout
{
MsgBox Timeout - I'll try later!
}
}
return
Escape::
ExitApp
return




