Advertisement
tolikpunkoff

zerofile.cmd

Feb 20th, 2019
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.85 KB | None | 0 0
  1. @echo off
  2.  
  3. if "%~1" EQU "" (
  4.     echo No arguments. Use  "%~n0%~x0  <filename> <size> [K|M]"
  5.     exit /b 1
  6. )
  7.  
  8. if "%~1" EQU "/?" (
  9.     echo Use  "%~n0%~x0  <filename> <size> [K|M]"
  10.     exit /b 1
  11. )
  12.  
  13. if "%~1" EQU "%~n1%~x1" (
  14.     set FILENAME=%CD%\%~1
  15. ) else (
  16.     set FILENAME=%~1
  17. )
  18.  
  19. set FILESIZE=%~2
  20. set ED=%~3
  21.  
  22. set /a "RES=FILESIZE+1-1"
  23. if %RES% LEQ 0 (
  24.     echo Can't create file with size %RES%
  25.     exit /b 2
  26. )
  27.  
  28. if "%ED%" EQU "K" goto :kb
  29. if "%ED%" EQU "M" goto :mb
  30. if "%ED%" EQU "k" goto :kb
  31. if "%ED%" EQU "m" goto :mb
  32. goto :create
  33.  
  34. :kb
  35.     set /a "RES=FILESIZE*1024"
  36.     set ST=%FILESIZE% Kb
  37.     goto :create
  38.  
  39. :mb
  40.     set /a "RES=FILESIZE*1024*1024"
  41.     set ST=%FILESIZE% Mb
  42.    
  43. :create
  44.     echo Creating file: %FILENAME%
  45.     if "%ST%" EQU "" (
  46.         echo Size:      %RES% bytes    
  47.     ) else (
  48.         echo Size:      %ST% [%RES% bytes]
  49.     )
  50.    
  51.     wsudo fsutil file createnew "%FILENAME%" %RES%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement