Saved Bookmarks
| 1. |
Solve : Using Forefiles Command? |
|
Answer» I need to automate deletion of folders.. This just attempts to delete files inside directory Backup Does this mean that files in Backup are DELETED? Post back with comments please. Hi.. Yeah..files inside the backup FOLDER is deleted. But not the folders. Again files (eg .txt, .LOG etc) inside subirectories are not deleted. It is inconsistent deletion of files too inspite of using /s command. Thanks for helping me.Quote forfiles /p c:\Backup /s /m *.* /d -7 /c "cmd /c del @file" Why are you using /s /m etc...? The site I linked shows the commands are -s -m etc... Is there an updated version of Forfiles, if so please post a link to it. Sorry - ignore that - found the newer version instructions here. Continuing to investigate... Update... Using the version of Forfiles which I have (10,512 bytes dated 2/13/1999): Forfiles -pc:\ -m*.dat lists the .dat files in C: -- however using the forward slash (/) instead of hyphen (-) Forfiles lists all files in C: showing that it is using all the default settings, not picking up the settings entered. I think this is probably due to me not having the most recent version of Forfiles and I've not been able to find a later version than mine. Also get ERROR 2 when trying to echo any of the variables (@file @ext etc...) Please post details of your copy of Forfiles. Thanks Hi Dusty forfiles command works only on Windows 2003 Server. I have c:\backup\test\test.txt Im using: forfiles /p c:\backup /s /m *.* /d -7 /c "cmd /c del @file" This command deletes test.txt Now I run, forfiles /p c:\backup /s /m *.* /d -7 /c "cmd /c rd @file" This command deletes folder 'test' because it is empty, but doesn't delete folder 'backup'. Apparently, it starts searching from the top. It sees 'test' folder inside 'backup' folder, so it doesn't delete 'backup' folder. But when it sees 'test' folder is empty, it deletes it.Sorry about the delay in responding. Quote forfiles command works only on Windows 2003 Server. I have not been able to get forfiles to perform on Win.98se (FAT32)(Command.com) or perform perfectly on Win.XP Home (NTFS)(Cmd.exe or Command.com). In 98se an error is displayed for every file forfiles tries to delete, in XP a few of the sub-directories are left behind (on one trial 3 out of 25) although all files are deleted. However using WIN2k (FAT32)(Cmd.exe) forfiles does exactly what is wanted, all files and subdirectories are deleted although the parent directory remains.. Had to use a 2-line bat script to achieve this, two passes of forfiles were required, one to delete files, second to delete sub-directories. Here it is: forfiles -pD:\temp\ -S -M*.* -c"CMD /C DEL @FILE /Q" forfiles -pD:\temp\ -S -M*.* -c"CMD /C if @ISDIR==TRUE RD @FILE /S/Q" I will try W2k with NTFS when hardware becomes available. Sorry, I do not have a copy of 2003 Server with which to test forfiles.. |
|