code_junkie

Separating 'body' of domain name from extension - DOS shell

Nov 13th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. @echo off
  2. echo.
  3. set domain=%~n1
  4. set ext=%~x1
  5. echo %DOMAIN%
  6. echo %EXT%
  7. echo.
  8.  
  9. D:Scriptstest>test.bat domain.com
  10.  
  11. domain
  12. .com
  13.  
  14. D:Scriptstest>test.bat domain.co.uk
  15.  
  16. domain.co
  17. .uk
  18.  
  19. @echo off
  20. cscript //Nologo test.js %*
  21.  
  22. if (WScript.Arguments.Length > 0) {
  23. var arg = WScript.Arguments.Item(0);
  24. var index = arg.indexOf('.');
  25. if (index != -1) {
  26. var domain = arg.substring(0, index);
  27. var ext = arg.substring(index);
  28. WScript.Echo(domain);
  29. WScript.Echo(ext);
  30. } else WScript.Echo("Error: Argument has no dots: " + arg);
  31. } else WScript.Echo("Error: No argument given");
  32.  
  33. C:Documents and SettingsWaqasDesktop>test.bat domain.com
  34. domain
  35. .com
  36.  
  37. C:Documents and SettingsWaqasDesktop>test.bat domain.co.uk
  38. domain
  39. .co.uk
Add Comment
Please, Sign In to add comment