Coder Social home page Coder Social logo

deletefiles's People

Contributors

rickstrahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deletefiles's Issues

"Simple File Specs"?

When indicating that you can delete files with "simple file specs", I was under the impression that the spec was simple.

I tried to delete all images that end with "*temp.jpg" and it didn't work. Am I 1) doing something wrong or is this a 2) bug or shortcoming of this script? If 2, is there a recommended workaround?

filespec does not work as expected

I have a number of top-level directories that are auto-created by a piece of software that apparently has a bug, because it does not clean them up and it makes sub-folder paths that are way over MAX_PATH length. These are all named according to the following "pattern": "C:\Temp_#+" In other words, the directory is made in the root of the C-drive, it's prefixed with the word "Temp", followed by an underscore, and a number (could be any number of digits, but at least one digit).

So I tried using DeleteFiles with an absolute path/filespec as follows:
DeleteFiles.exe c:\Temp_?* -r -f -l
This attempts to delete files and folders that are way different than what I would expect that filespec to cover. In fact, it's very dangerously traversing into the Windows directories, User directories, etc. Please see the output from that exact syntax from my server (attached, below).

If you look at the following directory listing (using the same filespec), you'll see what I expected to get purged by the program:
C:>dir c:\Temp_?*
Volume in drive C is SystemDisk
Volume Serial Number is 24AA-6D75

Directory of C:\

02/22/2017 08:53 AM

Temp_1234
02/22/2017 08:53 AM Temp_34
0 File(s) 0 bytes

test.txt

Delete Folder with symlink

Consider this file architecture :

-- root folder
---- subroot folder 1
---- subroot folder 2 (symlink)

Subroot folder 2 is a symlink created with the command : mklink /D myfolder c:/mypath

And when I delete the root folder, the application delete files inside subroot folder 2.

It should only remove the symbolic link ! This is very dangerous !

Bug: Hyphens in path to DeleteFiles can be misinterpreted as command switches!

Just noticed a fairly dangerous bug in the DeleteFiles utility, where if you're passing in the path to where the DeleteFiles.exe resides and that path contains hyphens, then they could be interpreted as command line switches by this function below:-

protected bool ParseParameterSwitch(string parm)    {        
    int at = CommandLine.IndexOf(parm,0,StringComparison.OrdinalIgnoreCase);
    if (at > -1) return true;
    return false;    
}

So for example, if I place DeleteFiles.exe in a folder called "C:\my-lol-utils" and call it by using the full path to DeleteFiles like this:-

C:\my-lol-utils\DeleteFiles c:\mystuff*. -d10

I would expect that to delete "mystuff" files over 10 days old. However, this doesn't happen because the folder "my-lol-utils" contains a hyphen followed by the letter L which is interpreted as "Display Mode" where it displays what would otherwise get deleted if that switch wasn't there, and so nothing gets actually deleted!

So not much harm there, but where it actually might get dangerous would be if I placed DeleteFiles.exe within a folder called "my-rofl-utils" and executed the same command again, e.g.

C:\my-rofl-utils\DeleteFiles c:\mystuff*. -d10

In this case, the "my-rofl-utils" contains a hyphen followed by the letter r which is interpreted as "Delete files [R]ecursively". Therefore rather than deleting old files just at the root of "mystuff" it would traverse every directory below "mystuff" as well deleting all the old files from each! This is totally unexpected!

The issue also happens where you prefix the filespec with a path, and that path also contains a hyphen. e.g.

DeleteFiles c:\my-reallygoodstuff*. -d10

The above statement would recursively delete all the files in and below "my-reallygoodstuff" again because the -r in the folder name is misinterpreted as a command switch for recursion!

At the very least, I think there should be a warning in the readme description warning about this situation.

While this is probably an edge case, it did in fact happen to me!

Add DeleteFiles in the NPM package install

Hi, is possible to install this tool from npm package that we could install globally for use?
This tool help me lot to remove npm nested package when the file name lager than windows support.

DeleteFiles Still Unable to Delete Long Paths

I'm finding that this utility still has an issue with npm long paths.
e.g.
The following long folder path can't be deleted:-

C:\Users\mcder_000\Dropbox\Temp\001_Week\_err\groupmail-templates\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow

The above path is 254 chars - I'm not sure if there are other paths nested below that, but that's as deep as I can see, from file explorer (on Windows 10) at any rate. From the face of it, that does appear to be the full path. There are no actual files along this path, only empty folders as presumably DeleteFiles was successful in removing those. File properties at the root '_err' folder show "0 files, 17 folders, 0 bytes".

So, running this command directly in the CMD.exe doesn't appear to remove the empty folders:-

DeleteFiles C:\Users\mcder_000\Dropbox\Temp\001_Week\_err\*.* -r -f

When I run it, it gives the following report:-

West Wind DeleteFiles [Version 1.14]


Failed to delete directory \\?\C:\Users\mcder_000\Dropbox\Temp\001_Week\_err\groupmail-templates\node_modules\gulp-imagemin\node_modules\imagemin\node_modules\imagemin-jpegtran\node_modules\jpegtran-bin\node_modules\logalot\node_modules\squeak\node_modules\lpad-align\node_modules\meow


Summary:
  No files found to delete.

Note that when I run the above command with the -l switch, it suggests that there is indeed 1 folders deleted. So, it would like to delete the folder, it just can't!

Any ideas?

Derek

Exclude folder name with -r -f

Hi,

Awesome project - great work!

Is there any way to exclude specific folder names, when using switches: -r -f. I cleanup the %TEMP% folder, but there some specific folders, that i would like to exclude ex. iisexpress.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.