Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. @echo off
  2.  
  3. if not [%3]==[] (
  4. goto usage
  5. )
  6.  
  7.  
  8. if [%2]==[] (
  9. goto usage
  10. )
  11.  
  12. if [%1]==[] (
  13. goto usage
  14. )
  15.  
  16. CALL SET arg=%2%
  17. CALL SET ext=%%arg:~1%%
  18.  
  19. if %arg%==* (
  20. forfiles /S /M %1 /C "cmd /c rename @file @fname
  21. ) else (
  22. forfiles /S /M %1 /C "cmd /c rename @file @fname%ext%"
  23. )
  24.  
  25. if %ERRORLEVEL%==0 (
  26. echo Successfully renamed the file extensions.
  27. )
  28. goto :eof
  29.  
  30. :usage
  31. echo Usage:
  32. echo TO rename file extension: rename.bat *.ext1 *.ext2"
  33. echo To strip file extension: rename.bat *.ext *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement