Solved pagination, convert file into page

September 5, 2011 at 04:01:17
Specs: Windows XP
I have several hundreds of files in folders I want to change each file into
a page so I would like to insert a unique word in the beginning of every

file (this step has been done)
I am looking for a batch file to find this unique word in 1st file and

replace it with digital number 1 and look for the same word in the 2nd

file and replace it with the digital number 2 and the 3rd file replace it

with 3 and so on
I am very greatful to any one who will help


See More: pagination, convert file into page

Report •


✔ Best Answer
September 19, 2011 at 02:04:30
I have tested the script as posted and have not found any problem with it. My input directory contains 4 files which are:

file01.htm

Jzeer
Cardiology
The epsilon potential is seen on the ECG of patients with which of the following?

file02.htm

Jzeer
Cardiology
In an asymptomatic patient, a permanent pacemaker is indicated in which of the following conditions?

file03.htm

Jzeer
Cardiology
Which of the following arrhythmias is unusual in digoxin toxicity?

file10.htm

now is the time
for all good men
to come to
the aid of


After running the script the output directory contains 4 files which are:

file01_new.htm

1
Cardiology
The epsilon potential is seen on the ECG of patients with which of the following?

file02_new.htm

2
Cardiology
In an asymptomatic patient, a permanent pacemaker is indicated in which of the following conditions?

file03_new.htm

3
Cardiology
Which of the following arrhythmias is unusual in digoxin toxicity?

file10_new.htm

4
for all good men
to come to
the aid of

Note that the first line of each input file has been replaced by the sequential number requested.


Please come back & tell us if your problem is resolved.



#1
September 7, 2011 at 20:57:29
Can I direct my request to Mr IVO or Mr Mechanic20 with many thanks

Report •

#2
September 11, 2011 at 06:24:52
Hello world Hello universe Hello Mechanix2go Hello IVO Hello every one
Please even a negative response to feel I am in living world!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Report •

#3
September 11, 2011 at 07:41:23
PROTIP: When soliciting help from specific users, make sure those users are still around. IVO hasn't posted any script since July 8. Mechanix2go has by all accounts up and left. (EDIT: His last post was on May 28.)

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 12, 2011 at 00:41:25
Ibrahim10 - Are the files named in any logical sequence? Files can be listed in many sequences, how are we to know what you consider is the 1st file, 2nd file, 3rd file etc?


Please come back & tell us if your problem is resolved.


Report •

#5
September 14, 2011 at 07:41:44
Thanks Razor 2.3 Thanks Wahine for your kind response
my files are htm and arranged alphabetcally according to their titles(long names) any help is very much appreciated
thanks again

Report •

#6
September 14, 2011 at 20:00:09
Okay, but now need to know if the unique word is the first line or just the first entry on the first line, also need to know the format e.g. is the unique word enclosed in < >

Can you post an example of the first line of any HTM file?


Please come back & tell us if your problem is resolved.


Report •

#7
September 15, 2011 at 04:54:46
To start with I would like to express my gratitude and respect to you Mr Wahine

the files wil be as follow
beginning of the 1st file
Jzeer
Cardiology
The epsilon potential is seen on the ECG of patients with which of the following?
-------------------------------------------
beginning of the 2nd file
Jzeer
Cardiology
In an asymptomatic patient, a permanent pacemaker is indicated in which of the following conditions?
-------------------------------------------------
beginning of the 3rd file
Jzeer
Cardiology
Which of the following arrhythmias is unusual in digoxin toxicity?
----------------------------------------------------
I would like the word "Jzeer" to be at the top of the file no need to be between html tags like < >
I want the word (jzeer) in the 1st file to be replaced with (1) and in the 2nd with (2) and in the 3rd with (3) and so on
Thanks a lot


Report •

#8
September 15, 2011 at 19:01:19
Am a little confused. You first say that you want the word Jzeer replaced by a number then your latest post states that you'd like Jzeer to be a the 'top' of the file then again repeat that it should be replaced. Do you want Jzeer to appear on line 1 followed by the number on line 2 of the output files?

Please test the following script which replaces Jzeer with the number. Post back if you need it to be amended.

@echo off
cls
setlocal enabledelayedexpansion

set /p indir=Enter path to input files:
cls

if not exist %indir% echo Input path "%indir%" not exist - job terminated&&exit/b

set /p outdir=Enter path for output files:
cls

If not exist %outdir% md %outdir%

pushd %indir%||echo Pushd failed - job terminated&&exit /b
set cnt=0


for /f "tokens=*" %%1 in ('dir /a-d /b /on "*.htm"') do (
    set filename=%%~n1
    set /a cnt+=1

     for /f "tokens=*" %%A in ("!filename!.htm") do (
         echo !cnt!>"c:\!outdir!\!filename!_new.htm"
         more +1 "!filename!.htm">>"c:\!outdir!\!filename!_new.htm"
    
    )
)
popd

Miss Wahine.


Please come back & tell us if your problem is resolved.


Report •

#9
September 16, 2011 at 06:24:57
Thanks Miss wahine morally you are distinct
Iam sorry to be unclear in making my point
I have inserted the word jzeer in the top of each file
I want this word to disappear from each file i.e replaced by a number say in the first file replaced by number (1) the same ward in the second file to be replaced by number (2) and in the third file to be replaced by number (3) and in the 4th file by number (4) so these digits will represent the page numbers
so I expect to find a place for the word jzeer in your script
please excuse me for the inconvenience I have caused you
Thanks a lot with my best regards

Report •

#10
September 18, 2011 at 06:20:11
Hello Wahine I hope you are fine, in good health and doing well and have strong will to help
unfortunately the script havent done the job an error message saying
"The filename, directory name, or volume label syntax is incorrect"

I tried writting input & output path with and without quots but the result is the same by the way input =C:\card and the output= C:\cardio
please let us forget about the word jzeer
is it possible to insert a serial number in the beginning of each file for example we insert (1) in the top of 1st file and number 2 in the 2nd file and 3 in the 3rd file and so on
the insertion of the serial numbers must be in the content of the file not their names
thanks in advance


Report •

#11
September 18, 2011 at 21:10:11
Sorry, the error you describe gives me no idea what is causing the problem. Please Rem the Echo Off command, run the script and post a few lines around where the error occurs.


Please come back & tell us if your problem is resolved.


Report •

#12
September 19, 2011 at 02:04:30
✔ Best Answer
I have tested the script as posted and have not found any problem with it. My input directory contains 4 files which are:

file01.htm

Jzeer
Cardiology
The epsilon potential is seen on the ECG of patients with which of the following?

file02.htm

Jzeer
Cardiology
In an asymptomatic patient, a permanent pacemaker is indicated in which of the following conditions?

file03.htm

Jzeer
Cardiology
Which of the following arrhythmias is unusual in digoxin toxicity?

file10.htm

now is the time
for all good men
to come to
the aid of


After running the script the output directory contains 4 files which are:

file01_new.htm

1
Cardiology
The epsilon potential is seen on the ECG of patients with which of the following?

file02_new.htm

2
Cardiology
In an asymptomatic patient, a permanent pacemaker is indicated in which of the following conditions?

file03_new.htm

3
Cardiology
Which of the following arrhythmias is unusual in digoxin toxicity?

file10_new.htm

4
for all good men
to come to
the aid of

Note that the first line of each input file has been replaced by the sequential number requested.


Please come back & tell us if your problem is resolved.


Report •

#13
September 19, 2011 at 22:31:37
Thank you very much Wahine
your effort and time is very much appreciated
you deserve my respect
thanks again and again

Report •


Ask Question