Cannot display a large record(Ex:more than 5000 characters)
Moderator: DosItHelp
-
- Posts: 5
- Joined: 21 Oct 2013 10:50
Cannot display a large record(Ex:more than 5000 characters)
0 down vote
Hi,
I've a file with record exceeding 5000 characters i use a .bat file to read the records but i cannot. I give the file name as a parameter to the . bat and the echo !temp! or echo %%a are empty . Is there any size limitation on the variable used in FOR or echo commands ?
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION set filename=nothing
SET i=0
for /f "usebackq tokens=*" %%a IN (%~1) DO (
echo %%aa set temp=%%~a echo !temp! echo !temp:~0,1000!>>a
)
Thanks for your help.
Hi,
I've a file with record exceeding 5000 characters i use a .bat file to read the records but i cannot. I give the file name as a parameter to the . bat and the echo !temp! or echo %%a are empty . Is there any size limitation on the variable used in FOR or echo commands ?
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION set filename=nothing
SET i=0
for /f "usebackq tokens=*" %%a IN (%~1) DO (
echo %%aa set temp=%%~a echo !temp! echo !temp:~0,1000!>>a
)
Thanks for your help.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Cannot display a large record(Ex:more than 5000 characte
I'm assuming the formatting got messed up when you didn't use the [ code] tags and it should actually look like
String length limit is 8191 characters. What system are you using? Strings of 5005 characters both echo to the command window and the first 1000 characters get appended to a file when I'm trying your script on Windows 7.
Code: Select all
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set filename=nothing
SET i=0
for /f "usebackq tokens=*" %%a IN (%~1) DO (
echo %%a
set temp=%%~a
echo !temp!
echo !temp:~0,1000!>>a
)
String length limit is 8191 characters. What system are you using? Strings of 5005 characters both echo to the command window and the first 1000 characters get appended to a file when I'm trying your script on Windows 7.
-
- Posts: 5
- Joined: 21 Oct 2013 10:50
Re: Cannot display a large record(Ex:more than 5000 characte
Thge system is: Windows 7 Entreprise 64bit Service Pack1.
I have a file which can contains record with 40000 characters, i have to split it file into sub files by sections , the file looks like:
/*START SECTION 1*/
blabla....
blabla..
..
/*END SECTION 1*/
/*START SECTION 2*/
blabla....
blabla..
..
/*END SECTION 2*/
/*START SECTION 3*/
blabla....
blabla..
..
/*END SECTION 2*/
/*START SECTION n*/
blabla..
..
/*END SECTION n*/
the containts of the sub file should be like (for example)
/*SECTION A*/
blabla....
blabla..
..
/*END SECTION A*/
So i made a .bat here it is:
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set filename=nothing
SET i=0
for /f "usebackq tokens=*" %%a IN (%~1) DO (
echo %%a
if "%%a"=="/*START *SECTION 1*/" (
set filename=export_SECTION.tmp
)
if "%%a"=="/*START *SECTION 2*/" (
set filename=export_SECTION2.tmp
)
.
.
.
echo !filename!
echo %%a >> !filename!
set /a i+=1
set i
)
it works fine for records which length near 2000 but if records length get bigger the echo %%a display empty string and the related record is not writ in the sub file.
Many Thanks
I have a file which can contains record with 40000 characters, i have to split it file into sub files by sections , the file looks like:
/*START SECTION 1*/
blabla....
blabla..
..
/*END SECTION 1*/
/*START SECTION 2*/
blabla....
blabla..
..
/*END SECTION 2*/
/*START SECTION 3*/
blabla....
blabla..
..
/*END SECTION 2*/
/*START SECTION n*/
blabla..
..
/*END SECTION n*/
the containts of the sub file should be like (for example)
/*SECTION A*/
blabla....
blabla..
..
/*END SECTION A*/
So i made a .bat here it is:
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set filename=nothing
SET i=0
for /f "usebackq tokens=*" %%a IN (%~1) DO (
echo %%a
if "%%a"=="/*START *SECTION 1*/" (
set filename=export_SECTION.tmp
)
if "%%a"=="/*START *SECTION 2*/" (
set filename=export_SECTION2.tmp
)
.
.
.
echo !filename!
echo %%a >> !filename!
set /a i+=1
set i
)
it works fine for records which length near 2000 but if records length get bigger the echo %%a display empty string and the related record is not writ in the sub file.
Many Thanks
Re: Cannot display a large record(Ex:more than 5000 characte
This uses a helper batch file called `findrepl.bat` from - https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
Place `findrepl.bat` in the same folder as the batch file.
It will extract the section to the console.
If you need further help to extract the sections, then describe the actual file makeup.
Place `findrepl.bat` in the same folder as the batch file.
It will extract the section to the console.
Code: Select all
type "file.ext" | findrepl "\/\*START SECTION 1\*\/" /e:"\/\*END SECTION 1\*\/"
If you need further help to extract the sections, then describe the actual file makeup.
-
- Posts: 5
- Joined: 21 Oct 2013 10:50
Re: Cannot display a large record(Ex:more than 5000 characte
Thanks for your response.
I try to run the findrepl.bat but it gives me "'findrepl.bat' is not recognized as an internal or external command,
operable program or batch file."
also i don't know how should i replace the " E:"?
if "%~1" neq "" if "%~1" neq "/?" goto begin
< "%~F0" CScript //nologo //E:JScript "%~F0" "^<usage>" /E:"^</usage>" /O:+1:-1
goto :EOF
:begin
CScript //nologo //E:JScript "%~F0" %*
exit /B %errorlevel%
:end
Thanks
I try to run the findrepl.bat but it gives me "'findrepl.bat' is not recognized as an internal or external command,
operable program or batch file."
also i don't know how should i replace the " E:"?
if "%~1" neq "" if "%~1" neq "/?" goto begin
< "%~F0" CScript //nologo //E:JScript "%~F0" "^<usage>" /E:"^</usage>" /O:+1:-1
goto :EOF
:begin
CScript //nologo //E:JScript "%~F0" %*
exit /B %errorlevel%
:end
Thanks
Re: Cannot display a large record(Ex:more than 5000 characte
btibti2013 wrote:I try to run the findrepl.bat but it gives me "'findrepl.bat' is not recognized as an internal or external command,
operable program or batch file."
Get `findrepl.bat` from - https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
Place `findrepl.bat` in the same folder as the batch file.
-
- Posts: 5
- Joined: 21 Oct 2013 10:50
Re: Cannot display a large record(Ex:more than 5000 characte
Many thanks it works fine now!
but i've to delete the first and the last line of a file how?
but i've to delete the first and the last line of a file how?
Re: Cannot display a large record(Ex:more than 5000 characte
remove the first and the last line of a text file:
Code: Select all
type text.txt|findrepl /o:2:-2
Re: Cannot display a large record(Ex:more than 5000 characte
If it is the same information you need to process, then add the /o switch section at the end.
Code: Select all
type "file.ext" | findrepl "\/\*START SECTION 1\*\/" /e:"\/\*END SECTION 1\*\/" /o:+1:-1
-
- Posts: 5
- Joined: 21 Oct 2013 10:50
Re: Cannot display a large record(Ex:more than 5000 characte
Yes! it works that's what i'am looking for thanks. I need to split the extracted file into sub files which contains n records each of them.
Re: Cannot display a large record(Ex:more than 5000 characte
Hi,
Could some one help..I am almost running into similar problem explained above. Trying to read a txt file of 4GB size.
The txt file only has a small string "This is just a sample line appended to create a big file. " appended to a big file of size 4 GB.
am using below to read the above (dummy) txt file
for /f "tokens=* delims=" %%x in (dummy.txt) do echo %%x
if the dummy file is just 1 GB I can see the display, when the size increases the script just display blank screen.
Could some one help..I am almost running into similar problem explained above. Trying to read a txt file of 4GB size.
The txt file only has a small string "This is just a sample line appended to create a big file. " appended to a big file of size 4 GB.
am using below to read the above (dummy) txt file
for /f "tokens=* delims=" %%x in (dummy.txt) do echo %%x
if the dummy file is just 1 GB I can see the display, when the size increases the script just display blank screen.
Re: Cannot display a large record(Ex:more than 5000 characte
For-In-Do can't read files past around 1 GB in size.
Explain what you need to achieve, and provide some details.
Explain what you need to achieve, and provide some details.
Re: Cannot display a large record(Ex:more than 5000 characte
I just need to read dummy large file usually (>10GB) to monitor my system processing read time.
For which I have created a dummy txt file that appends a string to create a large file and then read that file.
For which I have created a dummy txt file that appends a string to create a large file and then read that file.
Re: Cannot display a large record(Ex:more than 5000 characte
You need to read a file larger than 1 GB?
Why do you need to use for-in-do and what is the purpose of reading the file?
Why do you need to use for-in-do and what is the purpose of reading the file?
Re: Cannot display a large record(Ex:more than 5000 characte
Yes need very large files to capture the system time taken to read the large files.
I am pretty new to batch script, I used for-in-do as I only found that command for reading the contents from file. If there is any other command that would do the read job, could you suggest any?
I am pretty new to batch script, I used for-in-do as I only found that command for reading the contents from file. If there is any other command that would do the read job, could you suggest any?