March 5th, 2008, 11:55 AM
Bat file help
Does anyone have a bat file that can delete all files in a directory (and its subdirectory, and THAT ones subdirectory, and so on) while leaving the directory structure intact? We have an ftp that we put data on for users to get, and its usually about 200-300 mb each, and i want to wipe it out weekly. They're supposed to delete it when they download it, but you know how that is...
March 5th, 2008, 05:01 PM
Let me clear this a bit. The user downloads the folders and files from the ftp then you wanted to delete all files but leave the folders undeleted on the ftp.
Am i right?
March 5th, 2008, 06:51 PM
Yes. And all files in the sub directories and directories in those, but leaving the structure intact.
Originally Posted by zynder
They are *supposed* to be cleaning their files out once they are downloaded (we let them store large files on our server for other cities and counties to download), but they never do...
March 5th, 2008, 11:22 PM
I'm not good at bat files but this can be done effectively using a script or even much better an app jam packed with error handlers to ensure all files are deleted.
But, one question though. Are the folders changing? or is it static? Coz if it's not changing you can delete them all then recreate the directory.
March 6th, 2008, 01:50 AM
Just be careful if you choose to go with the delete + recreate, any custom permissions [aka ftp user access] are lost when the folder is deleted. The new folders will usually inherit permissions from their parent folder.
March 6th, 2008, 08:58 AM
Yea they have permissions on them that will need to be maintained. They are all static directories.
Originally Posted by fubes2000
March 6th, 2008, 12:00 PM
hmm, found it.
del /f /s /q basedirectory.
March 7th, 2008, 08:09 AM
If You Need a Complete batch Script then give this a go
This Will delete all the files in C:\temp and subdirectories
for /f "tokens=*" %%a in ('dir /b /a-d /s *.*') do del /f /q "%%a"