AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange delete pattern with FileRecycle and /*.*

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Wed Apr 13, 2005 7:44 pm    Post subject: Strange delete pattern with FileRecycle and /*.* Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Apr 13, 2005 11:25 pm    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Apr 14, 2005 12:35 am    Post subject: Re: Strange delete pattern with FileRecycle and /*.* Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Thu Apr 14, 2005 12:10 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Apr 14, 2005 1:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Thu Apr 14, 2005 3:35 pm    Post subject: Reply with quote

Maybe using a forward slash (/) rather than a backslash (\) is what's causing the problem. Confused
Back to top
View user's profile Send private message
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Thu Apr 14, 2005 4:46 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
DrSamRaza_1



Joined: 15 Apr 2005
Posts: 8
Location: Pakistan

PostPosted: Sat Apr 16, 2005 12:28 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Sat Apr 16, 2005 12:53 am    Post subject: Reply with quote

Smile 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
Back to top
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Sat Apr 16, 2005 12:54 am    Post subject: Reply with quote

Strange..
"FileRecycle, %1%" seems to be working for me with files and folders.

Maybe bugfix in recent update?
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Sun Apr 17, 2005 12:38 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Sun Apr 17, 2005 1:24 am    Post subject: Reply with quote

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%
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Serenity



Joined: 08 Nov 2004
Posts: 978

PostPosted: Sun Apr 17, 2005 1:27 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group