pleaviation.blogg.se

Delete file in cmd
Delete file in cmd












delete file in cmd

This is the same errors this question, but the answers there don't really work for me as I'm dealing with a directory, not a file, and I don't always know what specific files or subdirectories are causing the problem. Our ant script is somehow able to delete them when doing a clean, but sometimes I need to delete the workarea directory (where all the temp files go) without actually doing a full clean from ant. Our build process creates a number of temporary files (many build off of a WSDL) that run afoul of this limit. Normally this would not work, of course (you cannot copy files onto themselves), but since /L is stated, the file list is generated, but only if the switch /IS is given too (meaning that "same files" are to be regarded).Windows seems to have a length limit on file names when trying to delete, though it won't prevent those files from being created. The source and destination directories are both set to our target directory. Robocopy "%TARGETDIR%" "%TARGETDIR%" "%FILES%" ^Īfter having tested, remove the upper-case ECHO from the script to actually delete files.īesides /MIN, /MAX and /L, there are several other options defined in the robocopy command line, most of which care for the needed output, namely a simple list of full paths of matching files, without any extra information like headers, footers or summaries.

delete file in cmd delete file in cmd

Since we do not want to copy any files, use the /L option to list all the items that would be copied without the switch, then parse the returned list by a for /F loop, which holds the actual deletion command del in the body: set "TARGETDIR=." Hence the /MIN and /MAX options can be applied here. (If n < 1900 then n = n days, else n = YYYYMMDD date). MINLAD:n :: MINimum Last Access Date - exclude files used since n. MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n. MINAGE:n :: MINimum file AGE - exclude files newer than n days/date. MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date. MIN:n :: MINimum file size - exclude files smaller than n bytes. Here is an excerpt of the File Selection Options shown when robocopy /? is typed into the command prompt window: /MAX:n :: MAXimum file size - exclude files bigger than n bytes. Here is a different approach using robocopy and its filter capabilities.














Delete file in cmd