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). 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. In the below query, we copy all files from the source ( C:NPE) to the destination ( C:backups) directory. ![]() We can use the COPY command in the XPCmdShell for this purpose. 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=." 1 2 3 EXEC sp configure xpcmdshell, 1 GO RECONFIGURE Suppose we require copying files from one folder to another. ![]() 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |