Results 1 to 5 of 5

Thread: DOS problem

  1. #1
    Not responsible for WWI Citizen Bleys's Avatar
    Join Date
    Feb 2000
    Location
    The Wired
    Posts
    8,502
    Articles
    7
    Blog Entries
    60

    FFXIV Character

    Bleys Maynard (Sargatanas)
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default DOS problem

    Anybody know how to test if a replaceable parameter is a directory? if exist %1 returns true only if %1 is a <i>file</i>, not a directory.

    I need to write a batch file that reacts differently if %1 represents a null, a file, a directory, or anything else (i.e., if it's not "", and it's not a file or directory, it creates a new direcotory named %1)

    Also, anybody know how to extract filenames from a dir statement? I have to write another batch file which uses TYPE to display the contents of all read-only files.
    i.e.

    :startloop
    if "%1" == "" goto end
    type %1
    shift
    goto startloop

    :end

  2. #2
    KatanaSoul
    Guest

    Default

    For the directory vs file thing, I can only think to try cd %1 and test for an errorlevel.

    I don't think DOS supported any sort of regular expressions or output manipulation. I'd just as soon try it in C.

    In newer DOS versions, dir /b will show filenames plain, 1 per line. Type dir /? for details.

  3. #3
    Not responsible for WWI Citizen Bleys's Avatar
    Join Date
    Feb 2000
    Location
    The Wired
    Posts
    8,502
    Articles
    7
    Blog Entries
    60

    FFXIV Character

    Bleys Maynard (Sargatanas)
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    It's for school. We're not allowed to use real programming languages in the "batch files" section

  4. #4
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,393
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    I don't know of any batch command that'd let you check a parameter for filetype / directory. Why would you want to? Is it some sort of assignment?

    You can use DOSKEY to create a macro to overload what certain commands do, I think. Like you could overload "dir" to always mean "dir /s /w" or something. It's a way people used to save time, by not having to type all the commonly used switches every time they used a command. You could write a batch file that loads all the DOSKEY macros you need. I don't know if that helps. It's been awhile since I tried anything like that.

  5. #5
    Not responsible for WWI Citizen Bleys's Avatar
    Join Date
    Feb 2000
    Location
    The Wired
    Posts
    8,502
    Articles
    7
    Blog Entries
    60

    FFXIV Character

    Bleys Maynard (Sargatanas)
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    Yeah, it was for a school assignment. But never mind, I passed that module, with honors, I think, even though I slaiked that assignment.

    After using bash, I don't like DOS as much as I used to. DOSKEY is fine, but bash does all that without having to load a TSR. Yes, including macros. (alias lw='ls -F' is a good one)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •