- 1 year ago
Forfiles will cause this batch-file to hang after the last Y/N confirmation, and delete the specified directories, after which errors are generated
If your batch file is hanging after the last Y/N confirmation when using the forfiles
command, it's possible that the command is not being used correctly or is encountering errors.
Here are a few things you can try to resolve the issue:
Check the syntax of the
forfiles
command: Make sure that you are using the correct syntax for theforfiles
command. The command has several options and parameters that need to be specified correctly. Here's an example syntax for deleting files older than 7 days:bashforfiles /p "C:\path\to\directory" /s /m *.* /d -7 /c "cmd /c del @path"
Use the
del
command instead ofrd
: Instead of using therd
command to delete directories, try using thedel
command to delete the files inside the directories. This can help avoid issues with therd
command not being able to delete directories that still have files inside them.Check the permissions: Make sure that you have the necessary permissions to delete the directories and files. If you're running the batch file as a regular user, you may need to run it with administrative privileges.
Check for errors: If the batch file is generating errors after deleting the directories, it's possible that there are still files or directories that can't be deleted. Check the error messages to see if they provide any clues as to the cause of the issue.
By following these steps, you should be able to resolve the issue with the batch file hanging after the last Y/N confirmation and generating errors after deleting the directories.