[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. pushd c:\users
  2. dir /s /b outloook.* *.pst
复制代码

TOP

本帖最后由 apang 于 2012-2-17 01:30 编辑

回复 14# ppappa2001
  1.           for /f "delims=" %%j in ('dir /a-d /b "%RootFolder%\%%i\%SubFolder%\*.ost"') do (
  2.                 del /f /q "%%~dpnxj"&&echo 已删除%%~dpnxj >>delete.log
  3.           )      
  4.     )
复制代码
第10行及以下,改成这样试试

TOP

我知道我思路有问题, 但是怎样才能取得 被删除的文件列表喃?

TOP

本帖最后由 ppappa2001 于 2012-2-17 02:08 编辑

回复 17# apang


    改了以后 路径不对, 实际的路径 是: C:\Users\admin\AppData\Local\Microsoft\outlook;   程序当前路径是 c:\DOCUMENT\Desktop\

   另外能否解释下为什么要这样写喃? %%~dpnxj 这个变量的引入不是很理解.

Could Not Find c:\DOCUMENT\Desktop\test - Copy (2).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (3).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (4).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (5).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (6).ost
The system cannot find the path specified.
The system cannot find the file specified.
The system cannot find the file specified.
Could Not Find c:\DOCUMENT\Desktop\test - Copy (2).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (3).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (4).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (5).ost
Could Not Find c:\DOCUMENT\Desktop\test - Copy (6).ost
The system cannot find the path specified.

TOP

回复 14# ppappa2001
  1. @echo off
  2. for /f "delims=" %%i in ('dir /s /b "C:\Users\*.ost"') do (
  3.     del /f /q "%%i" && echo,%%i>>Delete.log
  4. )
复制代码

TOP

回复 19# ppappa2001
  1. @echo off
  2. set RootFolder=C:\Users
  3. set SubFolder=AppData\Local\Microsoft\Outlook
  4. for /f "delims=" %%i in ('dir /ad /b C:\users') do (
  5. REM  echo %RootFolder%\%%i\%SubFolder%\*.ost
  6.     for /f "delims=" %%j in ('dir /a-d /b /s "%RootFolder%\%%i\%SubFolder%\*.ost"') do (
  7.         del /f /q "%%~dpnxj"&&echo 已删除%%~dpnxj >>delete.log
  8.     )
  9. )
复制代码

TOP

学习了
vbs bat 业余爱好者

TOP

非常感谢楼上各位大侠的帮助.   代码调试通过了, 最后从格式上做了些美化. 执行的结果会写入当前路径 以当前日期为文件名的日志, 内容如下, 并附上代码, 谢谢大家.
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Administrator On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\

Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (2).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (3).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (4).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (5).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (6).ost 0

Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy (2) - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy (2).pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy.pst 0

删除了12个文件,一共为0KB
============================Below Files can't be Removed============================        
      

\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for All Users On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\

\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Default On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\

\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Default User On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\

\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for admin On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\
  1. @echo off
  2. ipconfig
  3. @echo -
  4. for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "Address"') do set ip=%%i
  5. cls
  6. REM @echo ==================[你的IP地址是:%ip%]===============
  7. REM  ====================================================
  8.    @ECHO OFF
  9. :: The Program only works on Windows English Version
  10. :: For Example
  11. :: The current date is: 05/27/2009 Wed
  12. :: Enter the new date: (mm-dd-yy)
  13.     ECHO.|DATE >temp1
  14.     FOR /F "eol=T tokens=5 delims=() " %%i in (temp1) do set date_format=%%i
  15.     FOR /F "eol=E tokens=5,6,7,8 delims=/- " %%a in (temp1) do (
  16.         IF /I %date_format% EQU mm-dd-yy ( set month=%%a
  17.                                            set day=%%b
  18.                                            set year=%%c
  19.                                            set week=%%d )
  20.         IF /I %date_format% EQU dd-mm-yy ( set day=%%a
  21.                                            set month=%%b
  22.                                            set year=%%c
  23.                                            set week=%%d )
  24.         IF /I %date_format% EQU yy-mm-dd ( set year=%%a
  25.                                            set month=%%b
  26.                                            set day=%%c
  27.                                            set week=%%d )      )
  28.    
  29.     SET current_date=%year%-%month%-%day%
  30.    
  31.     IF EXIST temp1 DEL /Q temp1
  32.     REM ECHO Current date = %current_date%
  33.     REM ====================================================
  34.      
  35.    
  36.     set RootFolder=C:\Users
  37.     set SubFolder=AppData\Local\Microsoft\Outlook
  38.     for /f "delims=" %%i in ('dir /ad /b C:\users') do (
  39.     REM  echo %RootFolder%\%%i\%SubFolder%\*.ost
  40.     REM  echo %current_date%.log
  41.     REM ====================================
  42.     setlocal enabledelayedexpansion
  43.     set n=&set ds=0
  44.     echo \\\\\\\\\\\\\\\\\\\\\\\\\%date%%time%, Deleting Files for %%i On %computername%, IP:%ip%\\\\\\\\\\\\\\\\\\\\\\\\\>>%current_date%.log
  45.     echo. >>%current_date%.log
  46.     if exist "%RootFolder%\%%i\%SubFolder%\*.ost" (              
  47.         for /f "delims=" %%j in ('dir /b/s %RootFolder%\%%i\%SubFolder%\*.ost') do (set /a n=!n!+1
  48.         echo Deleting %%j %%~zj>>%current_date%.log
  49.         del /q/f "%%j"
  50.         set /a ds=!ds!+%%~zj
  51.         )
  52.         
  53.         echo.>>%current_date%.log
  54.         for /f "delims=" %%j in ('dir /b/s %RootFolder%\%%i\%SubFolder%\*.pst') do (set /a n=!n!+1
  55.         echo Deleting %%j %%~zj>>%current_date%.log
  56.         del /q/f "%%j"
  57.         set /a ds=!ds!+%%~zj
  58.         )
  59.         
  60.         echo.>>%current_date%.log
  61.         echo 删除了!n!个文件,一共为!ds!KB>>%current_date%.log
  62.         
  63.         echo ============================Below Files can't be Removed============================>>%current_date%.log        
  64.         dir /d /b %RootFolder%\%%i\%SubFolder%\*.ost >>%current_date%.log     
  65.         dir /d /b %RootFolder%\%%i\%SubFolder%\*.pst >>%current_date%.log           
  66.         echo. >>%current_date%.log      
  67.         echo. >>%current_date%.log
  68.     )
  69.     REM End "If Exist on line58"
  70. )
  71. REM End "For on line48"
复制代码

TOP

返回列表