Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. DOS question

DOS question

Scheduled Pinned Locked Moved The Lounge
questionhelp
43 Posts 35 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E englebart

    Write a program in your favorite language on any platform to generate a throw away batch file. Don't waste too much time messing with all of the DOS quirks. DONT FORGET TO LEAVE ROOM FOR EXPANSION! 110 files today is 100,000 files tomorrow! example in C int i; for (i = 1; i <= 100; ++i) printf("ren L%d.txt L%5.5d.txt\r\n"); capture the output via: a.exe > myrename.bat myrename.bat

    R Offline
    R Offline
    Russell
    wrote on last edited by
    #41

    :laugh: yes...nice tip


    Russell

    1 Reply Last reply
    0
    • D da808wiz

      FYI, I would do it like this (from the command prompt, not from a batch file): for %f in (1 2 3 4 5 6 7 8 9) do rename L%f.txt L00%f.txt for %f in (1 2 3 4 5 6 7 8 9) do for %g in (0 1 2 3 4 5 6 7 8 9) do rename L%f%g.txt L0%f%g.txt that would work to rename the 1-99 files. The 100 file is already in that format. Sincerely G

      J Offline
      J Offline
      jsc42
      wrote on last edited by
      #42

      The code

      NuLiFree wrote:

      for %f in (1 2 3 4 5 6 7 8 9) do rename L%f.txt L00%f.txt for %f in (1 2 3 4 5 6 7 8 9) do for %g in (0 1 2 3 4 5 6 7 8 9) do rename L%f%g.txt L0%f%g.txt

      does not cater for missing entries. You could add 2>nul to the end of the renames to hide the errors, but the following (untested) would be safer and (in the second set) faster if some cases are not required:

      for %f in (1 2 3 4 5 6 7 8 9) do if exist L%f.txt rename L%f.txt L00%f.txt
      for %f in (1 2 3 4 5 6 7 8 9) do if exist L%f?.txt for %g in (0 1 2 3 4 5 6 7 8 9) do if exist L%f%g.txt rename L%f%g.txt L0%f%g.txt

      You might want to change the two occurrences of (1 2 3 4 5 6 7 8 9) to (0 1 2 3 4 5 6 7 8 9) to catch some erroneously named files.

      1 Reply Last reply
      0
      • B Bassam Abdul Baki

        Best tool ever.[^]

        B Offline
        B Offline
        blue lizard
        wrote on last edited by
        #43

        I've used this before and I totally agree.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups