Search found 3771 matches

by Squashman
17 Jul 2018 15:09
Forum: DOS Batch Forum
Topic: How to Create a File List with some modification using Simple Batch File
Replies: 9
Views: 75

Re: How to Create a File List with some modification using Simple Batch File

another bad thing from the above code is that if the folder name as "factory download" it treated as ..\factory\download\.. instead of ..\factory download\.. The DELIMS option is using a \ and SPACE as delimiters. Remove the space. And I am pretty sure you have been told this before but I will say ...
by Squashman
16 Jul 2018 13:13
Forum: DOS Batch Forum
Topic: URGENT! Problem with script from testing machine to production
Replies: 5
Views: 70

Re: URGENT! Problem with script from testing machine to production

Another best practice is to use double quotes for your string comparisons. If the variable you are comparing has any special characters or spaces, the IF command will fail.

Try to get in the habit of doing this.

Code: Select all

if not "x%endname:file1_xxxx_=%"=="x%endname%" command
by Squashman
13 Jul 2018 17:05
Forum: DOS Batch Forum
Topic: batch job to do string replacement of contents.lst file in all subfolders
Replies: 4
Views: 126

Re: new job to do a batch of replacement of contents.lst

You are forgetting about delayed expansion. The search, replace, newfile and textfile variables can be set outside the code block. No need to have them nested inside the FOR block. Shouldn't you be using %%G with the FINDSTR command? That is my best guess. I would think you would better understand y...
by Squashman
12 Jul 2018 14:32
Forum: DOS Batch Forum
Topic: batch job to do string replacement of contents.lst file in all subfolders
Replies: 4
Views: 126

Re: new job to do a batch of replacement of contents.lst

I would parse the output of the DIR command with a FOR /F command to get a listing of all the files.

Code: Select all

FOR /F "delims=" %%G IN ('dir /a-d /b /s contents.lst') DO........
by Squashman
10 Jul 2018 09:03
Forum: DOS Batch Forum
Topic: Doing MOD calculations in batch??
Replies: 3
Views: 15475

Re: Doing MOD calculations in batch??

Set /a a = 13 %% 5 I guess you misunderstood the previous comments in this thread. If you are running from a command prompt you use one percent symbol. Set /a a = 13 % 5 If you are running the code in a batch file then use two percent symbols. Set /a a = 13 %% 5 Look at Dave's explanation here .
by Squashman
06 Jul 2018 14:44
Forum: DOS Batch Forum
Topic: FindRepl.bat:New regex utility to search and replace strings
Replies: 130
Views: 75724

Re: FindRepl.bat:New regex utility to search and replace strings

Yes. Zero means it found it. Same errorlevel you would get if you were using the FIND and FINDSTR commands. If it finds the search string, the errorlevel is set to 0. If it doesn't find the search string the errorlevel is set to 1.
by Squashman
05 Jul 2018 20:59
Forum: DOS Batch Forum
Topic: Random number diff from cmd line vs double click
Replies: 17
Views: 2171

Re: Random number diff from cmd line vs double click

It still have a high rate of producing repeating results with successive calls in new instances of cmd (with both wmic and !time!) Hmm, I have let it run for a couple of minutes at a time and output thousands of results and have not gotten a duplicate when adding. Just reran a test using addition w...
by Squashman
04 Jul 2018 23:21
Forum: DOS Batch Forum
Topic: Random number diff from cmd line vs double click
Replies: 17
Views: 2171

Re: Random number diff from cmd line vs double click

Adding instead of multiplying seem to do the trick. I was roughly getting 674 strings generated a minute and when I was multiplying, I would roughly get 40+ strings with all zeros. When I changed to adding the seed, I got none. I tested two ways. REM Tested with these two lines set /a "hex=(!RANDOM!...
by Squashman
04 Jul 2018 20:46
Forum: DOS Batch Forum
Topic: Random number diff from cmd line vs double click
Replies: 17
Views: 2171

Re: Random number diff from cmd line vs double click

Digging up this old thread just because. I was commenting on a question at StackOverFlow that was now deleted by the user where they were using this code to generate a 32 character string. @echo off REM Delay in milliseconds for random number generator to recycle. REM pathping -p 2000 -q 1 localhost...
by Squashman
04 Jul 2018 10:19
Forum: DOS Batch Forum
Topic: JREPL - search based on position?
Replies: 5
Views: 194

Re: JREPL - search based on position?

HI Dave - Thank you so much! Works like an absolute charm!!! Also, how come JREPL won't work if you use a variable for the file name? For instance, this doesn't work: PUSHD "%HC_EXCEL_SUBPATH%%HC_ACT_SUBF%%YYYY_MMDD%" FOR %%A IN ("*.csv") DO ( SET "NAME=%%A" FOR %%a IN ( %LIST% ) DO ( SET "SKIP=" E...
by Squashman
04 Jul 2018 09:56
Forum: DOS Batch Forum
Topic: Help with set /a
Replies: 5
Views: 173

Re: Help with set /a

The code I gave you worked just fine when I tested it. I also fixed the problem with your results not actually being random! Not sure why you haven't tried to use it. Regardless of that you literally took Dave's advice and attempted to do it both ways you could possibly do it wrong. You need to esca...
by Squashman
03 Jul 2018 22:22
Forum: DOS Batch Forum
Topic: Help with set /a
Replies: 5
Views: 173

Re: Help with set /a

If you happened to read the help file for the SET command you may have noticed this comment. If you use any of the logical or modulus operators, you will need to enclose the expression string in quotes. setlocal enabledelayedexpansion FOR /L %%G IN (1,1,6) DO ( SET /A "rand%%G=!RANDOM! * (5 - 1 + 1)...
by Squashman
02 Jul 2018 06:24
Forum: DOS Batch Forum
Topic: Help with findstr
Replies: 3
Views: 169

Re: Help with findstr

You are overwriting the system PATH variable. When you did that, it can no longer execute the FINDSTR command because the location of the FINDSTR command is searched for within the system PATH variable.
by Squashman
29 Jun 2018 08:13
Forum: DOS Batch Forum
Topic: Need help with batch file
Replies: 3
Views: 167

Re: Need help with batch file

You can start by changing this.

Code: Select all

@ECHO OFF
setlocal EnableDelayedExpansion
SET workdir=%~dp1
SET myfile=%~nx1
SET myfilename=%~n1
SET filetype=%~x1
SET filesize=%~z1
SET convdir=%~d1ACONVERTED