Computer Hope
Microsoft => Microsoft DOS => Topic started by: jofspades on June 06, 2013, 02:40:53 PM
-
I got bored, and ran out of ideas for batch files.
Ideas? Anyone?
-
Sure. See if you can adapt the Vincenty formula into batch.
-
Have Fun... (http://www.wired.com/threatlevel/2013/06/analyst-who-cracked-kryptos/)
-
Add every file in a folder to a Zip archive.
Delete every file in a folder tree more than 5 days old.
(Probably easier in VBscript) find the square root of a number by Newton's method.
Shutdown the computer.
Reboot the computer.
Create 100 text files each one 1000 bytes in size with consecutively numbered names in the format text0001.txt text0002.txt etc
-
Write a secure password input system. (Harder than you would think)
-
a script to create a graph.
-
Delete every file in a folder tree more than 5 days old.
Create 100 text files each one 1000 bytes in size with consecutively numbered names in the format text0001.txt text0002.txt etc
Greetings Salmon Trout,
I liked the two above. Gave them a 'go' just for fun. For your consideration:
Delete every file:
@echo off
Robocopy C:\my_folder c:\my_del_folder /e /mov /minage:5
RD /s /q C:\my_del_folder
Create files: (ham fisted approach)
@echo off
Setlocal
call :make_file
:start
set /a #=#+1
set num=0000%#%
for /l %%b in (1,1,100) do (
type 1000.txt>text000%%b.txt
if %%b==100 goto :EOF
)
:make_file
for /l %%b in (1,1,25) do (
echo "999999999999999999999999999999999999">>1000.txt
if %%b==25 goto :start
)
They worked for me using WIN 7. I did limited testing.
Thoughts?
-
I used your methods in this modification Ocalabob
I think this format of filename was meant.
We should have contests on a task to see who's is smallest in bytes, or fastest, or most easily read etc. :)
@echo off
set c=10000
for /l %%b in (1,1,40) do (
>>tmp echo 12345678901234567890123
)
:loop
set /a c=c+1
set num=%c:~-4%
type tmp>text%num%.txt
if %c% LSS 10100 goto :loop
del tmp
-
@foxidrive
I tested your script. That's good work! Hat tip. :)
Now what about "Delete every file in a folder tree more than 5 days old."
-
fsutil file createnew C:\testfile.txt 1000
-
Now what about "Delete every file in a folder tree more than 5 days old."
forfiles /p c:\testfolder /s /d -5 /m *.* /c "cmd /c echo @PATH"
The echo command can be replaced with the del command. Use forfiles /? for more info.
8)
-
Now what about "Delete every file in a folder tree more than 5 days old."
You and Sidewinder have that sewn up. :)
-
(Probably easier in VBscript) find the square root of a number by Newton's method.
' sqr (N) is approx equ to 0.5 * (N/A + A)
N = wscript.arguments(0)
A = 1
D = 1
Do Until D = 0
C = (N/A + A) / 2
D = A - C
A = C
Loop
wscript.echo "Square root of " & N & " = " & C
This can be done in batch...
-
@Salmon Trout
Reboot the computer.
Batch file using WIN 7.
C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
foxidrive? :)
-
HuH ? ?
-
Maybe I was too brief. :)
::Devcon_Reboot.bat
::@echo off
C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
-
shutdown /r
REM this one saves your applications
shutdown /g
-
@Lemonilla
I was trying for something more esoteric just for fun. Your solutions are more 'real world'. Hat tip! :)
-
@Salmon Trout
Batch file using WIN 7.
C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
foxidrive? :)
Devcon is a Microsoft command line utility that is not a standard part of Windows; you have to download it. It is a developer tool, a command line equivalent of Device Manager, and I should think that used carelessly by someone with little knowledge or sense of responsibility it could seriously disrupt a computer. However you can reboot the computer with no need for extras in one line like this:
@shutdown /r /t X
where X is the number of seconds you want to wait before rebooting, 0 (zero) being immediately.
-
beaten by page 2 :)
-
@Salmon Trout
Batch file using WIN 7.
C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
foxidrive? :)
Why wouldn't you just use the SHUTDOWN command.
-
Why wouldn't you just use the SHUTDOWN command.
Welcome to the chorus...
-
::Devcon.exe from microsoft
@echo off
Devcon Reboot
There wouldn't have been any comment if the path wasn't there and the point it was from Microsoft was made. :)
After all, this thread is about figuring out different ways to write batch files... :)