Advertisement
Guest User

Untitled

a guest
Jun 4th, 2010
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. :: Delete.Duplicate.Video.Files.bat
  2. @ECHO OFF
  3. SETLOCAL ENABLEDELAYEDEXPANSION
  4.  
  5. SET file_path=%~1
  6. FOR /F "delims=" %%a IN ('DIR /B /S /O:N "%file_path%\*.mkv" "%file_path%\*.avi"') DO (
  7. CALL :get_file_info "%%a"
  8. SET old_file=!new_file!
  9. SET old_file_date=!new_file_date!
  10. SET new_file=!file_name!
  11. SET new_file_date=!file_date!
  12. FOR /F %%b IN ('@ECHO "!old_file!"^|FIND /C "!new_file!"') DO (
  13. IF "%%b" EQU "1" (
  14. IF !old_file_date! GTR !new_file_date! (
  15. ECHO older: !new_file_date! !new_file!
  16. ECHO newer: !old_file_date! !old_file!
  17. DEL "%file_path%\!old_file!.*"
  18. ECHO.
  19. )
  20. IF !new_file_date! GTR !old_file_date! (
  21. ECHO older: !old_file_date! !old_file!
  22. ECHO newer: !new_file_date! !new_file!
  23. DEL "%file_path%\!new_file!.*"
  24. ECHO.
  25. )
  26. IF !new_file_date! EQU !old_file_date! (
  27. ECHO same: !old_file_date! !old_file!
  28. ECHO same: !new_file_date! !new_file!
  29. ECHO Same timestamps. No files deleted...
  30. ECHO.
  31. )
  32. )
  33. )
  34. )
  35. EXIT /B
  36.  
  37. :get_file_info
  38. SET file_date=%~t1
  39. FOR /F "tokens=1-4 delims=: " %%c IN ("%file_date%") DO (
  40. SET hours=0%%d
  41. SET hours=!hours:00=!
  42. SET hours=!hours:~-2!
  43. IF %%d LSS 12 (
  44. IF "%%f" EQU "PM" (
  45. SET /A hours=%%d+12
  46. )
  47. )
  48. SET file_date=%%c !hours!:%%e
  49. )
  50. SET file_name=%~n1
  51. GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement