![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-28 05:08 |
47,813 topics / 349,918 posts / today 0 new / 48,277 members |
| DOS批处理 & 脚本技术(批处理室) » How to automatically delete empty folders |
| Printable Version 3,105 / 14 |
| Floor1 wxs81514 | Posted 2008-05-15 09:11 |
| 初级用户 Posts 52 Credits 118 | |
|
Ask everyone:
I want to set up a batch script to automatically delete empty folders every day, because the automatic backup program I made will copy empty folders. |
|
| Floor2 HAT | Posted 2008-05-15 10:04 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Which command does your automatic backup program use? Check if that command has a built-in switch to skip empty folders.
|
|
| Floor3 wxs81514 | Posted 2008-05-15 10:34 |
| 初级用户 Posts 52 Credits 118 | |
|
The batch processing is written like this:
robocopy D:\ \\zhixinserver\%computername%\Other_new_files\Disk_D *.doc *.xls *.ppt *.dwg *.cdr *.pdf /s /xa:h /maxage:30 /mir I only want the files that have been updated in the last 30 days. Files older than this date are automatically deleted. But when I add /mir, empty folders appear. |
|
| Floor4 HAT | Posted 2008-05-15 14:46 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Can /PURGE and /S be used instead of /MIR?
|
|
| Floor5 plp626 | Posted 2008-05-15 14:57 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
This is the code in the forum, I will quote it:
|
|
| Floor6 wxs81514 | Posted 2008-05-15 15:22 |
| 初级用户 Posts 52 Credits 118 | |
|
Okay, thank you very much! Now there's no need to figure out how to delete empty folders.
There's another question I'd like to ask: When backing up with the above command, can certain folders be excluded from the operation, such as "recycled", which is the recycle bin. |
|
| Floor7 wxs81514 | Posted 2008-05-15 15:28 |
| 初级用户 Posts 52 Credits 118 | |
|
Or you don't need to back up hidden folders. Because "recycled" is a hidden folder
|
|
| Floor8 HAT | Posted 2008-05-15 15:40 |
| 版主 Posts 5,017 Credits 9,023 | |
Originally posted by wxs81514 at 2008-5-15 03:28 PM: You must be careful when reading the help document ^_^
|
|
| Floor9 wxs81514 | Posted 2008-05-15 19:03 |
| 初级用户 Posts 52 Credits 118 | |
|
Thanks, my English is not very good, I can't understand it very well, but after being specified, I still understand it, and it worked, but a new problem appeared:
When backing up, I want to exclude {Documents and Settings}, but if I write it in, the computer thinks it is three folders, namely "Documents", "and", "Settings". How can I make it recognize it as one folder. |
|
| Floor10 HAT | Posted 2008-05-15 19:37 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Try adding double quotes for directories with spaces.
|
|
| Floor11 wxs81514 | Posted 2008-05-16 10:18 |
| 初级用户 Posts 52 Credits 118 | |
|
HAT is really amazing, knows everything, and it worked at first try.
|
|
| Floor12 wxs81514 | Posted 2008-05-16 10:48 |
| 初级用户 Posts 52 Credits 118 | |
|
HAT, hello, I don't know how to address you? Thank you for solving a series of problems for me during this time. It has enabled me to learn a lot and has been of great help to my work. There are still three post problems, which are more troublesome. I don't know if you haven't seen them or I want to ask for advice. Even providing some ideas would be good. The post topics are as follows:
1. Batch create users by reading computer names and passwords from files 2. Synchronize server time with administrator privileges 3. Detect and automatically cancel sharing 4. How to make computers in the LAN back up in a specified order |
|
| Floor13 wxs81514 | Posted 2008-05-16 15:07 |
| 初级用户 Posts 52 Credits 118 | |
|
I'm getting a new issue when using the following code:
robocopy C:\ \\zhixinserver\%computername%\Other_new_files\Disk_F *.doc *.xls *.ppt *.dwg *.cdr *.pdf /xd "Documents and Settings" "Program Files" recycler recycled WINDOWS winnt /xa:h /maxage:30 /PURGE /S The target folder is not files updated within 30 days, but an incremental backup. |
|
| Floor14 bg5hfc | Posted 2008-05-16 15:24 |
| 新手上路 Posts 2 Credits 4 | |
Originally posted by wxs81514 at 2008-5-16 10:48 AM: Try to search more by yourself before asking For the first one, write user passwords in the format of username : pass in the file, read them with for, then use net user username \"pass\" /add net localgroup administrators username /add To add, replace administrators with users for adding restricted users For the second one, first modify the registry to specify the time synchronization server, specifically see http://bbs.nfan.org/read.php?tid=42382 For the third one, I don't know if you want to cancel or disable net share c$ /delete net share d$ /delete .... For disabling, just use net stop Server to disable the service directly For the fourth one, I don't understand, what does specified order backup mean .. [ Last edited by bg5hfc on 2008-5-16 at 03:26 PM ] |
|
| Floor15 wxs81514 | Posted 2008-05-16 15:58 |
| 初级用户 Posts 52 Credits 118 | |
|
Friend on the 14th floor, thank you. I also spent a long time looking up these problems before posting. For the third one, I want to prohibit the use of the sharing function. I would like to ask: net stop Server, I have learned that it will stop all network servers, including the messenger and so on. Can I only stop the sharing service?
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |