Search found 52 matches

by Rekrul
2023-Jul-27, 8:19 am
Forum: Windows CMD Shell
Topic: Does "endlocal" close all instances of "setlocal"?
Replies: 6
Views: 10425

Re: Does "endlocal" close all instances of "setlocal"?

I'm just curious: How many of you use setlocal by itself and not paired with enabledelayedexpansion, or enableextensions? It seems to me that the only real use for setlocal by itself is to be able to temporarily re-use variables. Which seems like a great way to confuse yourself and make debugging ha...
by Rekrul
2023-Jul-18, 12:05 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27720

Re: Use SED to extract part of a line?

I thought this script was finished, but then I downloaded an NZB that it didn't work on. I had assumed (yes, I know what they say about assuming) that all posts today would be using the yEnc format. I happened to download an NZB for a post that wasn't. Or the posting software didn't put "yEnc&q...
by Rekrul
2023-Jul-17, 11:58 pm
Forum: Windows CMD Shell
Topic: How do I escape > in grep in a for loop???
Replies: 1
Views: 8486

Re: How do I escape > in grep in a for loop???

Well, after MUCH experimentation, I discovered that this works in a script;

Code: Select all

@echo off
set Tag=\"^>
setlocal enabledelayedexpansion
for /f %%E in ('grep -c "!Tag!" "%Filename%"') do endlocal & set Count=%%E
echo %Count%
[/quote]
by Rekrul
2023-Jul-17, 8:17 pm
Forum: Windows CMD Shell
Topic: How do I escape > in grep in a for loop???
Replies: 1
Views: 8486

How do I escape > in grep in a for loop???

I need to use grep to find the number of lines containing the sequence of characters; "> This works when entered directly into the command line and gives me the count of matching lines; grep -c "\">" "filename.txt" This does not; for /f %E in ('grep -c "\">&qu...
by Rekrul
2023-Jul-13, 5:38 am
Forum: Windows CMD Shell
Topic: Best way to send contents of text file to the DIR command?
Replies: 2
Views: 8447

Re: Best way to send contents of text file to the DIR command?

I don't think there is a more elegant native way. OK, thanks. Incidentally, you probably want to protect your file names, vars with quotes -- in case of spaces/special characters. Also there is a hard limit to the length of a variable, so if you have a lot of entries a pseudo-array would probably b...
by Rekrul
2023-Jul-11, 9:16 am
Forum: Windows CMD Shell
Topic: Best way to send contents of text file to the DIR command?
Replies: 2
Views: 8447

Best way to send contents of text file to the DIR command?

I have a text file containing just filenames, one per line.I want to send those filenames to the DIR command so that they can be sorted by date and output to a new text file in that order. The best I could come up with is this; @echo off set Names= for /f %%F in (List.txt) do ( set Name=%%F call :Ad...
by Rekrul
2023-Mar-22, 8:10 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27720

Re: Use SED to extract part of a line?

Nice solution :) Thanks. :) I know I said it was done, but I couldn't resist making a couple tweaks to the way it handles lists passed to it from a file manager. Previously, it simply counted the lines in the list file that was passed to it and defaulted to processing all the NZB files in the direc...
by Rekrul
2023-Mar-22, 7:39 am
Forum: Windows CMD Shell
Topic: Ampersand and exclamation mark in concatenated variable
Replies: 2
Views: 1872

Re: Ampersand and exclamation mark in concatenated variable

I was browsing the forum and saw your message. This should do what you want with any legal filename; @echo off set tracks= for /r %%i in (*.mp3) do ( set name="%%i" call :AddTrack ) c:\apps\foobar2000\foobar2000.exe /tag:GUESS:"%%TRACKNUMBER%%. %%TITLE%%":%%_FILENAME%% %tracks% g...
by Rekrul
2023-Mar-20, 8:01 am
Forum: Windows CMD Shell
Topic: For loops: Is there any reason you HAVE to use different tokens?
Replies: 1
Views: 2144

For loops: Is there any reason you HAVE to use different tokens?

The other day while looking for something else, I stumbled across a web page where a user stated that since some other characters can be used as tokens in a For loop, it was possible to create more than 26 nested loops. The thing is that, other than for readability, there doesn't seem to be any need...
by Rekrul
2023-Mar-17, 4:57 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27720

Re: Use SED to extract part of a line?

Unless I find any bugs, I'm declaring my NZB fixer script done. I added progress updates to the title bar, displaying the number of the file being processed as well as how many headers within that file have been fixed. I added protections against poison characters in the filenames being Echoed to th...