loading

Tricky batch stuff...?

This isn't exactly a conventional question, but it's a question nonetheless. 

The thing is, I'm thinking of starting a forum for all the tricky techniques and methods with batch (it wouldn't be a great instructable as it would require a lot of previous knowledge). So, I'd basically just have an index with all these different segments of how to do tricky stuff (such as advanced techniques for piping and other random stuff).

The only problem is that I don't know what to make it on, so I'm trying to target people who've read all the instructables and are still missing that extra bit of information.

Now, you could say something like "do whatever you think is hard", but the thing is I work better when it's at the request of someone else (basically I like to help people, and I'm abusing that natural urge).

So, if you're experienced in batch but are curious about anything (perhaps how to ignore every rule in the book and put 50 nested for loops within your script), please post it below.

Thank you.

--EDIT--
I've started rewriting my batch tutorial, so most of the stuff you comment will go into that... somewhere.

sort by: active | newest | oldest
Wisaam4 years ago
I used to program batch a long time ago, now I use C++ and java. But still I have something to ask.
How do we make a program in batch that takes input from a text file from a specific line and puts it in a variable?

Actually I know how to take input but I don't know how to take input from specific lines like I want to take input from line 5 and then from 7.
Prof. Pickle (author)  Wisaam4 years ago
Well, using the skip option in a for loop, I've come up with this (it's untested but it looks sound enough)...

@echo off & setlocal enabledelayedexpansion
set num=0
for /f "skip=4" %%i in (file_path) do (
set /a num+=1
if !num! equ 1 set line5=%%i
if !num! equ 3 set line7=%%i
)

Note, replace file_path with the actual path to the file.

You could very easily make this script shorter and faster, but I've given you the basics.

Also, there are many more ways to do this, but I thought of this one first.
I don't get it at all. Why not just use a proper programming language rather then struggle in something as antiquated as batch programming
Prof. Pickle (author)  steveastrouk4 years ago
I've already moved on to higher level programming languages, but I'm not good enough in them to be of any use to people. It's basically there for those who don't want to put the effort into using another language but want to learn more advanced techniques with batch instead.
Prof. Pickle (author) 4 years ago
Plus, you get a digital cookie if you answer :)