Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Batch Problems - MODE & Enum Loop

Posted on 2009-06-27
4
Medium Priority
?
343 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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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 …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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