AutoHotkey Community

It is currently May 26th, 2012, 7:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: April 13th, 2005, 7:44 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Below is a line from a script designed to be launched from the Explorer shell menu that deletes files to the Recycle Bin. If launched from clicking on a folder, this will delete all files/folders inside that folder.

Code:
FileRecycle, %1%/*.*


The problem is when this line is executed when the path variable is empty - I've ran this script from different locations (up to five subdirectories deep) and the pattern is the same in that it deletes all the files located at the drive root ie x:\ and some but not all folders. Is this to be expected?

ahk 1.0.30.02
win2k sp4

ps - If you are going to test this, empty your Recycle Bin first, and check it after running this once.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 13th, 2005, 11:25 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
That filepattern would only match folders that had a period in their names. If you want to truly purge the directory, try %1%\* instead. (braindump)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 14th, 2005, 12:35 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Serenity wrote:
The problem is when this line is executed when the path variable is empty...
I'm assuming you mean the %1% variable and not %Path%.

Quote:
...it deletes all the files located at the drive root ie x:\ and some but not all folders. Is this to be expected?
It might just be what Jonny says, but I've also looked over the code and it's not doing anything unusual. In fact, all it's doing is calling a function built into Windows Explorer, which you can read about here in case you spot something ususual that I missed: SHFILEOPSTRUCT Structure


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2005, 12:10 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Thanks for the tip Jonny, I'll try that now. Fwiw, none of the folders it deleted here had a period in their names. I can't see a predictable pattern other than deleting files at the root of the drive. Surely *.* should delete files in the folder in which the script was executed from? Perhaps the / changes the directory level somehow.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2005, 1:46 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Serenity wrote:
Perhaps the / changes the directory level somehow.
A leading backslash does indeed refer to the root of the current drive. Therefore, if %1% is blank, the wildcard pattern would be \*.*, which refers to the root of the current working directory's drive. Sorry I missed that before.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2005, 3:35 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
Maybe using a forward slash (/) rather than a backslash (\) is what's causing the problem. :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 14th, 2005, 4:46 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Using a forwardslash produces the same delete pattern as a backslash, so it doesn't appear to make a difference.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 12:28 am 
Offline

Joined: April 15th, 2005, 11:36 pm
Posts: 7
Location: Pakistan
May be I can help if I knew a little more from your code.

Please post, not all but a little more code is needed before a suggestion can be made

_________________
Intelligence helps, but hard work is the key to Success


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 12:53 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
:) The EmptyFolder script is actually very small:

Code:
; empty folder to recycle bin

#notrayicon
#singleinstance force

var = %1% ; bug fix for running as standalone exe in folder

if var =
  exitapp
else

FileRecycle, %1%/*.* ; when click on folder, this deletes the contents of that folder

; if executed as standalone, this section will not delete anything
loop, %1%
{
  FileRecycle, %A_LoopFileDir%/*.*
; when click on file, this will delete all files/folders in the current folder
; when click on folder this does nothing
}
ExitApp

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 12:54 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Strange..
"FileRecycle, %1%" seems to be working for me with files and folders.

Maybe bugfix in recent update?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2005, 12:38 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
When you say working, do you mean it deletes files/folders? Does it delete anything when the %1% variable is empty?

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2005, 1:24 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Serenity wrote:
Does it delete anything when the %1% variable is empty?
If %1% is blank it doesn't delete anything. If %1% contains files, folders, or multiple files/folders it just recycles them all. Is this what you wanted or are you having problems with it? Remember to check other parts of your script if anything to see if it's interfearing with it.

FileRecycle, %1%

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 17th, 2005, 1:27 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Thanks for clarifying. The problem I was getting was with this line:

Code:
FileRecycle, %1%/*.*


When the %1% was empty I was getting strange delete patterns.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, chenhaiyang, kkkddd1, Leef_me, Tilter_of_Windmills and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group