In this case, the lock is the pushd as you can not remove the current working folder.
Well here is my code but I just can not filter the listing using the objFile Extension i am sure it is some thing silly Set objFSO = CreateObject('Scripting.. /E Edit ACL instead of replacing it /x Edit ACL instead of replacing it; affect only ACEs that this user already owns * /R user Revoke all access rights from the given user.. txt ECHO # Press any key to exit Dec 15, 2015 Hi, again This is my code: must delete files and (sub)folders but leaving parent folder ' Delete all Subfolders and Files in a Folder Const.. >>%logfile_name% txt ECHO # Done >>%logfile_name% txt ECHO # Log file =%logfile_name%.. ECHO Folder 1 cleaned >>%logfile_name% txt GOTO clear_1_done:clear_1_done GOTO final:final ECHO.
Hope it helps Again, test and test again before going live @ECHO OFF ECHO # Starting.. Vbs Delete All Files In A Folder And Subfolders Html5You can use Robocopy to move files to a temp directory and then delete that temp directory.. ECHO [ERROR] The folder 1 does not exist >>%logfile_name% txt GOTO final ):folder_1_exists REM now we will delete the files in the first folder REM first we create the temporal folder MKDIR%path_temp_folder% REM now we move the files older than X (in this case 30) days to that folder ROBOCOPY%folder_1_path%%path_temp_folder% /s /mov /minage:30 >nul REM ROBOCOPY syntax = source destination [file [file]] [options] REM and finally as stated we delete the temporal folder RMDIR%path_temp_folder% /s /q ECHO Folder 1 cleaned.
![](http://www.patterson-consulting.net/onlinedocs/testdesignstudio/walkthrough5.png)
![](http://blog.vilmatech.com/wp-content/uploads/2014/01/xp_start_search.gif)
![](http://3.bp.blogspot.com/-4p1nqkelQ9o/UhvzXQsAjGI/AAAAAAAAFIE/WNkbn3RSuUU/s1600/C%2523-Get-Files-From-Folder-SubFolders-in-Asp.net.gif)
Sep 10, 2014 From command line, the easiest way to do it is for /d%a in ('d: users *') do (pushd '%~fa' && (rmdir.. /s /q 2>nul & popd)) That is, for each of the subfolders, place a lock in it to avoid to it to be removed.. Syntax XCACLS filename [ options] XCACLS filename Key If no options are specified XCACLS will display the ACLs for the file(s) options can be any combination of: /T Traverse all subfolders and change all matching files found.. Here is sample of moving the files to a temp directory that are over thirty days old and then deleting them.. bat launched at%time% >%logfile_name% txt ECHO >>%logfile_name% txt REM Program Start REM variables - here just write the paths of the folders you want to clear SET folder_1_path='D: HG HSI temp' REM this next variable will be the path of the temporal folder (you can write whatever path you want as it will be deleted) SET path_temp_folder='D: temptrash deleteme' REM first we will check if the folders specified in the path variables exists IF EXIST%folder_1_path% ( GOTO folder_1_exists ) ELSE ( ECHO [ERROR] The folder 1 does not exist.. DateLastModified File Delete end if Next for each Folder in objSubFolders Recurse Folder Next Set objSubFolders = Nothing Set objFiles = Nothing end Sub.. So, do the same in SubFolders Set objFiles = objFolders Files for each File in objFiles if File.. In your case you may be able to use /MOV be careful with this command for it deletes files, be sure to test first. e828bfe731