Search found 442 matches

by orange_batch
09 Dec 2011 19:06
Forum: DOS Batch Forum
Topic: Trouble with ftp batch file.
Replies: 6
Views: 2491

Re: Trouble with ftp batch file.

Are you trying to copy an HTML file? Try copying in binary mode instead of ASCII. I don't know why a file transfer would be processed through the command interpreter, but it seems you're encountering a < at +escape(< in an HTML file.
by orange_batch
09 Dec 2011 18:56
Forum: DOS Batch Forum
Topic: XCOPY folder wildcard?
Replies: 13
Views: 12571

Re: XCOPY folder wildcard?

Valthero sorry, xcopy is trying to find that file which may or may not exist in each of the paths... easy fix. Also, when 2>nul fails, >nul 2> or >nul 2>&1 should work. Try the code above again, I made the necessary changes. Provide the path in question with all wildcards marked and I'll see wha...
by orange_batch
09 Dec 2011 18:52
Forum: DOS Batch Forum
Topic: Finding and replace an string in a text file
Replies: 3
Views: 2228

Re: Finding and replace an string in a text file

Sounds like someone wants us to do their school homework? Preserve all quotation marks. 1) A script that finds a specific string in a text file so that it is replaced with another string. @echo off&setlocal enabledelayedexpansion set file="my_text.txt" set out="result.txt" se...
by orange_batch
09 Dec 2011 18:48
Forum: DOS Batch Forum
Topic: "For /f" string needs to run only once
Replies: 6
Views: 2468

Re: "For /f" string needs to run only once

Can be used any number of times in your scripts, as goto will always go to the first label found after where it's executed. Of course, you can't go to a specific break though if you have multiple copies. Actually you can re-use the same label like this BECAUSE it always goes to the first matching l...
by orange_batch
09 Dec 2011 18:34
Forum: DOS Batch Forum
Topic: Speed Writing a File
Replies: 17
Views: 7410

Re: Speed Writing a File

Well, it may not be needful for you but I have a mind like a steel sieve Heavy comments in the code are one way I save myself when something breaks and I haven't programmed in that language for a while. If you find the code useful, by all means remove the comments and use it all or in part - I don'...
by orange_batch
09 Dec 2011 18:11
Forum: DOS Batch Forum
Topic: Using a Variable in String Manipulation
Replies: 4
Views: 2419

Re: Using a Variable in String Manipulation

Yep that too, that's what I meant by "like" :) I never have a full list of problematic characters in my head. :o
by orange_batch
09 Dec 2011 04:54
Forum: DOS Batch Forum
Topic: Redirecting Ouput Issue.
Replies: 3
Views: 1605

Re: Redirecting Ouput Issue.

You don't want to use a temp file. strlen should already set the length to a variable which you can use or transfer to another variable. If it doesn't, modify it. For any command that outputs to the screen, you can catch that output and set it to a variable using: for /f "delims=" %%a in (...
by orange_batch
09 Dec 2011 03:25
Forum: DOS Batch Forum
Topic: String encrytion and decryption
Replies: 11
Views: 9343

Re: String encrytion and decryption

It's hard to say. It's best if your strings never contain quotation marks, then you can freely use " and " surrounding your text to deactivate special character interpretation. But even then you will have problems with exclamation marks if delayed expansion is enabled (but you can selectiv...
by orange_batch
09 Dec 2011 03:20
Forum: DOS Batch Forum
Topic: "For /f" string needs to run only once
Replies: 6
Views: 2468

Re: "For /f" string needs to run only once

Here's a solution that should be better than Ed's, since it doesn't keep iterating doing nothing but if defined comparisons, this is how you typically break out of a for loop in batch. Pseudo-code: for ... ... ( code ... goto break ) :break Can be used any number of times in your scripts, as goto wi...
by orange_batch
09 Dec 2011 03:04
Forum: DOS Batch Forum
Topic: XCOPY folder wildcard?
Replies: 13
Views: 12571

Re: XCOPY folder wildcard?

You need to build an array of folders matching the first wildcard, then build another array of folders matching the second from the first array, then process that list through your xcopy command all with for loops. I'm pretty sure wildcards only work on the last part of a path. @echo off&setloca...
by orange_batch
08 Dec 2011 22:56
Forum: DOS Batch Forum
Topic: Find the amount of characters in a string after SET /P
Replies: 8
Views: 4290

Re: Find the amount of characters in a string after SET /P

Indeed, I use bitwise operations for anything involving powers of 2. alleypuppy: http://www.dostips.com/forum/viewtopic.php?f=3&t=1429&p=5537#p5537 I could also explain it as-is. It is based on adding bits together and seeing if the input string contains characters at the bits represented va...
by orange_batch
08 Dec 2011 22:33
Forum: DOS Batch Forum
Topic: Speed Writing a File
Replies: 17
Views: 7410

Re: Speed Writing a File

Good. Commenting is good practice too. However I personally would use that as source, and have a working copy that's stripped and minified. No need on such a short script though.
by orange_batch
07 Dec 2011 01:17
Forum: DOS Batch Forum
Topic: Using a Variable in String Manipulation
Replies: 4
Views: 2419

Re: Using a Variable in String Manipulation

You're on the right track. The first case doesn't work because, command prompt reads from % to % to determine variables: IF /I %VAR:~% num %,1% =="A" [do commands] With delayed expansion, it reads as: IF /I !VAR:~ %num% ,1! =="A" [do commands] This should work, except the problem...
by orange_batch
07 Dec 2011 00:32
Forum: DOS Batch Forum
Topic: Help with ECHO variable after FOR-IN-DO(SET /A [var]%%f)
Replies: 4
Views: 2781

Re: Help with ECHO variable after FOR-IN-DO(SET /A [var]%%f)

Patte, like dbenham said, you can change @ECHO OFF at the top to @ECHO OFF&SETLOCAL EnableDelayedExpansion and ECHO COUNTER_%%f to ECHO !COUNTER_%%f! . Or, you can change ECHO COUNTER_%%f to CALL ECHO %%COUNTER_%%f%% (slower but no need for delayed expansion). As for your code, I don't recommend...
by orange_batch
06 Dec 2011 01:07
Forum: DOS Batch Forum
Topic: Why does SET performance degrade as environment size grows?
Replies: 31
Views: 18896

Re: Why does SET performance degrade as environment size gro

My only guess is that, like how DOS checks locations for filenames associated with commands etc, maybe it runs through all data in the environment to find and modify an existing variable's memory address (and allocate more if made larger) or to find a new memory address for a new variable? I don't k...