| View previous topic :: View next topic |
| Author |
Message |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Wed Apr 13, 2005 7:44 pm Post subject: Strange delete pattern with FileRecycle and /*.* |
|
|
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 |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Wed Apr 13, 2005 11:25 pm Post subject: |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Thu Apr 14, 2005 12:35 am Post subject: Re: Strange delete pattern with FileRecycle and /*.* |
|
|
| 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 |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Thu Apr 14, 2005 12:10 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Thu Apr 14, 2005 1:46 pm Post subject: |
|
|
| 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 |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Thu Apr 14, 2005 3:35 pm Post subject: |
|
|
Maybe using a forward slash (/) rather than a backslash (\) is what's causing the problem.  |
|
| Back to top |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Thu Apr 14, 2005 4:46 pm Post subject: |
|
|
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 |
|
 |
DrSamRaza_1
Joined: 15 Apr 2005 Posts: 8 Location: Pakistan
|
Posted: Sat Apr 16, 2005 12:28 am Post subject: |
|
|
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 |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Sat Apr 16, 2005 12:53 am Post subject: |
|
|
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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Sat Apr 16, 2005 12:54 am Post subject: |
|
|
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 |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Sun Apr 17, 2005 12:38 am Post subject: |
|
|
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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Sun Apr 17, 2005 1:24 am Post subject: |
|
|
| 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 |
|
 |
Serenity
Joined: 08 Nov 2004 Posts: 978
|
Posted: Sun Apr 17, 2005 1:27 am Post subject: |
|
|
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 |
|
 |
|