Solved

Batch Problems - MODE & Enum Loop

Posted on 2009-06-27
4
332 Views
Last Modified: 2012-05-07
I am creating a batch file that had MODE working at one point, but upon addition of some lines, it stopped working. I removed the added lines, it still did not work yet. Will also not work in any other BATCH file i make. Works however in a command prompt environment. The code for the MODE command is:

MODE CON COLS=55 LINES=28


I am also having issues with an enumeration listing of files in a directory, I use a FOR to add 1 to a enumeration variable and attempt to echo the number without the file name attached to it, it will simply say "1" and then go to the next file, it will not add but it will go back to just showing "1", with a single line of output being "11111111111111" or so. The variable after it is set i checked and it is set to 1, til i run the code again, it will than be incremented once more. I gave up on this code and am requesting perhaps someone knows a better way to enumerate the list out in a format such as

# - FOLDER NAME

1 - a
2 - b
3 - c
4 - d
5 - e
0
Comment
Question by:meepee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 21

Accepted Solution

by:
AmazingTech earned 100 total points
ID: 24730099
The mode command should work. I'm not too sure what the problem you're having with it.

Here's a simple way to get the numbering of the folders.
@Echo Off
SETLOCAL ENABLEDELAYEDEXPANSION
set folder=1
for /f "tokens=*" %%a in ('dir /ad /b') do (
    echo !folder!,%%a
    Set /a folder+=1
)

Open in new window

0
 

Author Comment

by:meepee
ID: 24730225
im having issues with some similar commands, such as IPCONFIG -- however if i change directory to %SystemRoot%\system32\, it seems to pick it up just fine (and it still works when i go to change directory afterwards) but when reloaded the cmd prompt, it will go back to saying it cant be found. I just did a fresh install of windows about a week ago. Doubt it could be file corruption this early since i hadnt installed anything new that i didnt use before and that happened a few days after i got all of it on here. I reset my PATH variable and that did not help at all on that matter.

As for your batch code, it is acceptable, it works to the way i need it to, not sure why i was unable to do that successfully before.
0
 

Author Comment

by:meepee
ID: 24730258
Nevermind, i have figured out the problem concerning the not recognizing of any commands - i forgot that there were two sets of PATH variables, the global one was set correctly, but at some point the local PATH variable (which overrides global if present) was set incorrectly. It appears to have been set to my Visual Studio 6.0 C++ bin folder. Which has never happened to me before. I award full points to you AmazingTech
0
 

Author Closing Comment

by:meepee
ID: 31597610
I thank you for the time you provided me.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question