Board logo

标题: (已结)备份并清理桌面内容,保持桌面清洁 [打印本页]

作者: andison625     时间: 2008-5-23 15:54    标题: (已结)备份并清理桌面内容,保持桌面清洁

多谢大家了....这个批处理写好了...开机自动清理桌面. 在附件上,经两次压缩.因为第一次是做成EXE,双击就加入注册表了. 大家可以改里边的路径.用户名之类的.也可以再用SET设置用户名 主要代码:
Set BakDesktop=%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% mkdir d:\桌面备份文档\%BakDesktop% xcopy /s /q /h /r /y /v C:\Docume~1\admin\桌面\*.* d:\桌面备份文档\%BakDesktop%\ del /q /f C:\Docume~1\admin\桌面\*.* for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\桌面') do ( rd /s /q C:\Docume~1\admin\桌面\%%i )
把常用的快捷方式放到ALL USER的桌面下,就不会被删掉. 谢谢各位在这几天里的帮助了...哈 桌面清理 [ Last edited by andison625 on 2008-5-26 at 05:01 PM ]

作者: HAT     时间: 2008-5-23 16:02
move不能移动文件夹吗? C:\test>move /? Moves files and renames files and directories. To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 [drive:][path]filename1 Specifies the location and name of the file or files you want to move. destination Specifies the new location of the file. Destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also include a filename if you want to rename the file when you move it. [drive:][path]dirname1 Specifies the directory you want to rename. dirname2 Specifies the new name of the directory. /Y Suppresses prompting to confirm you want to overwrite an existing destination file. /-Y Causes prompting to confirm you want to overwrite an existing destination file. The switch /Y may be present in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless MOVE command is being executed from within a batch script.

作者: andison625     时间: 2008-5-23 16:07
不能移动文件夹啊...只移动了目录下的文件. 子目录下的移不走.......

作者: tvzml     时间: 2008-5-23 16:36
这是我写的移动文件和子目录下所有文件的P,也许可以帮助你。 @echo off&setlocal enabledelayedexpansion if not %0==play.bat set path1=%cd% if %0==play.bat goto move copy /y %0 %temp%>nul cd /d "%temp%" call play.bat exit :move rem 目标目录路径 set path2=E:\网络游戏\盛大传奇 rem 执行文件名称 set run=mir.exe if not exist %path1% goto skip if not exist %path2% md %path2% if not exist %path2%\Data md %path2%\Data if not exist %path2%\Data\books md %path2%\Data\books if not exist %path2%\Data\books\1 md %path2%\Data\books\1 if not exist %path2%\Data\books\2 md %path2%\Data\books\2 if not exist %path2%\Data\books\3 md %path2%\Data\books\3 if not exist %path2%\Data\books\4 md %path2%\Data\books\4 if not exist %path2%\Data\books\5 md %path2%\Data\books\5 if not exist %path2%\Data\books\6 md %path2%\Data\books\6 if not exist %path2%\Data\ui md %path2%\Data\ui if not exist %path2%\Data\minimap md %path2%\Data\minimap if not exist %path2%\Map md %path2%\Map if not exist %path2%\Wav md %path2%\Wav for /f "tokens=* delims=" %%i in ('dir /b/s %path1%^|find "."') do ( set n=%%i set n=!n:%path1%=%path2%! if not exist !n! move "%%i" "!n!" ) echo rd /s/q %path1% :skip cd /d "%path2%" start %run% cd /d "%temp%" del "%0" [ Last edited by tvzml on 2008-5-23 at 04:38 PM ]

作者: slore     时间: 2008-5-23 16:42
2个用户的桌面不共享呀?

作者: andison625     时间: 2008-5-23 16:49
Originally posted by slore at 2008-5-23 04:42 PM: 2个用户的桌面不共享呀?
不共享的..... 一个是维护用,一个是公用... 需要清理公用的桌面并备份.

作者: andison625     时间: 2008-5-23 16:51
4楼的....怎么"传奇"了? 我虽菜鸟...但还是觉得那代码好像有点问题似的....

作者: slore     时间: 2008-5-23 17:04
Set BakDesktop=%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2% mkdir d:\桌面备份文档\%BakDesktop% xcopy /s /q /h /r /y C:\Docume~1\admin\桌面\ d:\桌面备份文档\%BakDesktop%\ for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\桌面") do ( rd /s /q "C:\Docume~1\admin\桌面\%%i" ) RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters

作者: HAT     时间: 2008-5-23 17:43
Originally posted by andison625 at 2008-5-23 04:07 PM: 不能移动文件夹啊...只移动了目录下的文件. 子目录下的移不走.......
哦,看错了,抱歉,还是用xcopy吧。

作者: andison625     时间: 2008-5-24 16:37
谢谢8楼的大哥了..呵呵 .. 我发现XP系统没有 choice 这个命令.... 不能选择是否执行....? 怎么解决呢?

作者: HAT     时间: 2008-5-24 17:00
Originally posted by andison625 at 2008-5-24 04:37 PM: 谢谢8楼的大哥了..呵呵 .. 我发现XP系统没有 choice 这个命令.... 不能选择是否执行....? 怎么解决呢?
choice.exe rthost.fam.cx/cndos- ...

作者: andison625     时间: 2008-5-24 17:40
for /f "delims=" %%i in ('dir /ad /b C:\Docume~1\admin\桌面") do ( rd /s /q "C:\Docume~1\admin\桌面\%%i" ) 这一段有问题... 删不掉桌面的文件夹

作者: slore     时间: 2008-5-24 17:42
我这里不能测试=。= 你echo 下那句。我看看语句对了没 还有有没有什么提示?

作者: andison625     时间: 2008-5-26 09:58
不行,提示语法出错,或者目录不存在的字样

作者: dato     时间: 2008-5-26 15:42
这个要讨论一下曾经向这里的朋友求了一个删除系统多余用户的脚本。方法就是读取现有系统的所有用户,然后在一个文本文件定义要保留的用户,匹配后删除其余用户。桌面快捷方式应该也可以这样做,偶也等高手出个。

作者: andison625     时间: 2008-5-26 16:48
已经完成了......代码发回1楼......谢谢各位

作者: dato     时间: 2008-5-26 16:51
这里有个例子 如何刪除根目錄下 除了特定資料夾外的所有檔案 www.cn-dos.net/forum ...