Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Things to Program  (Read 10015 times)

0 Members and 1 Guest are viewing this topic.

jofspades

  • Guest
Things to Program
« on: June 06, 2013, 02:40:53 PM »
I got bored, and ran out of ideas for batch files.
Ideas? Anyone?

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Things to Program
« Reply #1 on: June 06, 2013, 02:51:59 PM »
Sure.  See if you can adapt the Vincenty formula into batch.

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: Things to Program
« Reply #2 on: June 06, 2013, 03:12:14 PM »
" Anyone who goes to a psychiatrist should have his head examined. "

Salmon Trout

  • Guest
Re: Things to Program
« Reply #3 on: June 06, 2013, 03:53:19 PM »
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



Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Things to Program
« Reply #4 on: June 06, 2013, 06:32:31 PM »
Write a secure password input system. (Harder than you would think)
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Things to Program
« Reply #5 on: June 06, 2013, 07:42:35 PM »
a script to create a graph.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Ocalabob



    Rookie

    Thanked: 4
    • Experience: Familiar
    • OS: Windows 7
    Re: Things to Program
    « Reply #6 on: June 06, 2013, 09:08:36 PM »
    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:
    Code: [Select]
    @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)
    Code: [Select]
    @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?




    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Things to Program
    « Reply #7 on: June 06, 2013, 11:49:15 PM »
    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. :)

    Code: [Select]
    @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

    Ocalabob



      Rookie

      Thanked: 4
      • Experience: Familiar
      • OS: Windows 7
      Re: Things to Program
      « Reply #8 on: June 07, 2013, 05:36:15 AM »
      @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."

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: Things to Program
      « Reply #9 on: June 07, 2013, 06:41:36 AM »
      fsutil file createnew C:\testfile.txt 1000

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Things to Program
      « Reply #10 on: June 07, 2013, 07:26:51 AM »
      Quote
      Now what about "Delete every file in a folder tree more than 5 days old."

      Code: [Select]
      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)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: Things to Program
      « Reply #11 on: June 07, 2013, 09:37:27 AM »
      Now what about "Delete every file in a folder tree more than 5 days old."

      You and Sidewinder have that sewn up. :)

      Salmon Trout

      • Guest
      Re: Things to Program
      « Reply #12 on: June 09, 2013, 01:53:46 PM »
      (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...

      « Last Edit: June 09, 2013, 02:10:54 PM by Salmon Trout »

      Ocalabob



        Rookie

        Thanked: 4
        • Experience: Familiar
        • OS: Windows 7
        Re: Things to Program
        « Reply #13 on: June 14, 2013, 07:08:23 PM »
        @Salmon Trout
        Quote
        Reboot the computer.

        Batch file using WIN 7.

        Code: [Select]
        C:\"Program Files (x86)"\O2Micro\Oz600\Devcon Reboot
        foxidrive? :)

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Re: Things to Program
        « Reply #14 on: June 14, 2013, 07:27:29 PM »
        HuH ? ?
        " Anyone who goes to a psychiatrist should have his head examined. "