Home / Microsoft / Microsoft DOS / need help! need a batch script to delete certain data from a .c file
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: need help! need a batch script to delete certain data from a .c file  (Read 399 times)
Raven19528
Hopeful



Thanked: 29
Posts: 284

Computer: Specs
Experience: Experienced
OS: Windows 7



« Reply #15 on: January 31, 2012, 06:06:08 PM »

Funny, I did something almost exactly the same, but I was away from my computer for an extended period.

The code below iterates what you are wanting. You can either use this or Squashman's code (use in place of the second FOR loop in mine) and it should give you the results that you are looking for.

Code: [Select]
@echo off
setlocal enabledelayedexpansion
set switch=0

for /f "delims=" %%A in ('dir /s /b *.c') do (
  for /f "delims=^( tokens=1*" %%B in (%%A) do (
    if !switch! equ 0 (
      if "%%B"=="ROM_START" (set switch=1)
      echo %%B^(%%C >>temp.txt
    )
    if !switch! equ 1 (
      if "%%B"=="ROM_END" (
        set switch=0
        echo ROM_END >> temp.txt
      )
    )
  echo del %%A
  echo ren temp.txt %%~nxA
  )
)

Same rules as above with the removing the echo and adding move if needed. Let us know how this works.
IP logged

"All things that are
Are with more spirit chased than enjoy'd" -Shakespeare
daillest319
Topic Starter
Rookie



Posts: 16

Experience: Beginner
OS: Unknown

« Reply #16 on: January 31, 2012, 06:54:21 PM »

Thank you raven and squashman for all your help  ;D
IP logged
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / need help! need a batch script to delete certain data from a .c file « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.111 seconds with 19 queries.