![]() |
| >>> Click
here to download Final Fantasy Ringtones |
| |
#1 Anybody know how to test if a replaceable parameter is a directory? if exist %1 returns true only if %1 is a file, 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 |
| | |
| |
| | 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. |
| |
| | 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. |
| | |
| | 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) |
| | |