Computing.Net > Forums > Programming > Find then compare two #'s in batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Find then compare two #'s in batch

Reply to Message Icon

Name: pball
Date: November 4, 2008 at 15:22:25 Pacific
OS: XP Pro
CPU/Ram: 2.8 ghz / 2 gig
Manufacturer/Model: home made
Comment:

I get files often that have a crc checksum in the file name but no premade sfv to check it with. So I run the file through quicksfv and open the sfv file and compare the value in the file name and the actual crc after it. If they match the file is complete.

I would like a batch file to search a sfv file and find the two crc numbers in each line and compare them if they are the same it goes on if not it would echo the whole line it was working on.

This is an example line in the file.

[a-s]_yu_yu_hakusho_001_-_surprised_to_be_dead__[ma]debito_dvd-rip__[8CBE991C].ogm 8CBE991C

The listed crc is inside of the [] brackets and the actual crc is one space behind the file name. The ext and everything after the [ bracket should be constant, as in the number of characters won't change. If that would help any.

I do not know how to search and return text which I assume would be a good wat to do this.

I would think a quick and dirty way of doing this would be to find the [ then set everything behind it to a variable then compare the 1st-8th characters from the variable to 14th-22nd characters

can't find any good thread on finding things in a txt file or i'd cobble something together first then ask for help.


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: BatchFreak
Date: November 4, 2008 at 16:39:05 Pacific
Reply:

so in the above example whaat would you want to extract?

I only Batch if possible, 2000 more lines of code, oh well.


Report Offensive Follow Up For Removal

Response Number 2
Name: pball
Date: November 4, 2008 at 16:51:18 Pacific
Reply:

Well to put it simply I want to compare 8CBE991C and 8CBE991C (which are the same at this time).

If your talking about my harebrained idea it would be setting this 8CBE991C].ogm 8CBE991C (everything after the [) to a var then I could use what i know know to get parts of that variable.


EDIT
I just remembered something that might help, it's something someone made for me before for something else.

call :parse %%x

:parse
SET element=%1

IF "%element%"=="%element:~-3%" IF "%element:~0,1%"=="T" (SET num=%element:~-2%& GOTO :EOF)
IF NOT "%title%"=="" (SET title=%title% %1) ELSE SET title=%1
SHIFT
GOTO parse

This was made to get the two characters after the letter T. I have no clue how it works, but I think this could be reworded into finding the [ and setting the rest of the line to what's behind it instead of the next two characters.

link to that thread
http://www.computing.net/answers/pr...


Report Offensive Follow Up For Removal

Response Number 3
Name: pball
Date: November 4, 2008 at 19:24:38 Pacific
Reply:

Well a new post since I made something that works almost. Only problem is it's case sensitive. not any more



@echo off

setlocal enabledelayedexpansion
for /f "usebackq tokens=*" %%x in ("E:\Anime\Yu Yu Hakusho\[a-s]_yu_yu_hakusho_001_-_surprised_to_be_dead__[ma]debito_dvd-rip__[8CBE991C].sfv") do (
call :check %%x
if /I not "!z:~0,8!" == "!z:~14,22!" echo %%x
set z=
)

goto end

:check
set x= %1 %2
:again

if "%x:~-1%" == "[" set s=%z% & goto :EOF

set z=%x:~-1%%z%

set x=%x:~0,-1%

goto again

:end
pause

couple of questions:
how can I get it to find any sfv file in the folder it's ran in? so i don't need to add the name there.


Report Offensive Follow Up For Removal

Response Number 4
Name: Razor2.3
Date: November 4, 2008 at 19:49:27 Pacific
Reply:

Untested, and it'll break if the file name has spaces:

@FOR /F "tokens=1,2" %%a IN (*.sfv) DO @(ECHO %%a | FIND "%%b" >NUL || ECHO %%a)

Command Scripts don't do logic well, so it's best to keep it simple.

Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Find then compare two #'s in batch

Comparing files/ lists with batch www.computing.net/answers/programming/comparing-files-lists-with-batch/12686.html

Compare two numbers w/Batch www.computing.net/answers/programming/compare-two-numbers-wbatch/15835.html

Compare file names in batch file www.computing.net/answers/programming/compare-file-names-in-batch-file/16616.html