Computing.Net > Forums > Disk Operating System > numbering the filename sequence

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

numbering the filename sequence

Reply to Message Icon

Name: hyde
Date: August 12, 2003 at 00:35:38 Pacific
OS: DOS
CPU/Ram: 512
Comment:

Can som1 help me. I have a txt file with a list of swf filenames in it seperated by a break.
example:

somefile.swf
other.swf
3rd.swf

what i'd like to do is to change the format so this:

&1=somefile.swf&2=other.swf&3=3rd.swf and so on until it runs out of names. it has to have no spaces. plz help



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: August 12, 2003 at 12:58:49 Pacific
Reply:

I can do that with a batch file, but I would need to know your exact OS. If you're under Windows, report its version, not simply "DOS".

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: Secret_Doom
Date: August 12, 2003 at 13:02:10 Pacific
Reply:

It would be quite easy to do it with an assembler program, actually easier than in batch, perhaps Elmar (plop) can develop it...

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 3
Name: Secret_Doom
Date: August 12, 2003 at 13:38:44 Pacific
Reply:

Nevermind, I already developed a solution in C and sent to hyde via email. Here's the source code:

#include <stdio.h>

void main(void) {

    int c,n;
    n = 1;
    c = '\n';

    while (c != EOF) {
        if (c == '\n') {
            while (c == '\n') c = getchar();
            if (c == EOF) return;
            printf("&%d=%c", n, c);
            ++n;
        }
        else {
            putchar(c);
        }
        c = getchar();
    }
}

Forgive any bad syntaxes, I'm far from being as good in C as in batch =D

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

______________________________________________________


0

Response Number 4
Name: hyde
Date: August 12, 2003 at 14:08:49 Pacific
Reply:

I am using win XP
can you send me the batch code please


0

Response Number 5
Name: Secret_Doom
Date: August 12, 2003 at 14:19:53 Pacific
Reply:

I already sent you the solution in C, but it seems your email account is deactivated.

If you'd prefer the batch solution, I would need to know in which OS it should run.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Related Posts

See More



Response Number 6
Name: hyde
Date: August 12, 2003 at 14:50:40 Pacific
Reply:

it will run im windows xp i am not sure which version of dos i have


0

Response Number 7
Name: Secret_Doom
Date: August 12, 2003 at 17:53:25 Pacific
Reply:

Oh, sorry, you had reported your OS version at the time of my last post... I don't know what happened that I didn't process that information...

So, WinXP then. This should do it:

@echo off
if "%1"=="GoTo" goto %2
%comspec% /v:on /c %0 GoTo start
goto:eof
:start
echo XPYP[*'CC-\1P\QX,=P,APZ5O!PQ2O~5aaI~}Ksx> %temp%.\$.com
set N=1
type nul> OutFile
for /F "tokens=*" %%S in (InFile) do (
    %temp%.\$.com &!N!=%%S>> OutFile
    set /A N += 1
)
del %temp%.\$.com

It will get the information on InFile and build OutFile with the new format. If you want InFile and OutFile to be the same file (don't want to keep the original file), use something like this (using as example the filename MyFile.txt):

@echo off
if "%1"=="GoTo" goto %2
%comspec% /v:on /c %0 GoTo start
goto:eof
:start
echo XPYP[*'CC-\1P\QX,=P,APZ5O!PQ2O~5aaI~}Ksx> %temp%.\$.com
set N=1
type nul> %temp%.\$.dat
for /F "tokens=*" %%S in (MyFile.txt) do (
    %temp%.\$.com &!N!=%%S>> %temp%.\$.dat
    set /A N += 1
)
type %temp%.\$.dat > MyFile.txt
del %temp%.\$.dat
del %temp%.\$.com

That's it.

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br

___________________________________________________________________


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: numbering the filename sequence

partions problems www.computing.net/answers/dos/partions-problems/13223.html

How do I get the certificate of authenticity number in dos www.computing.net/answers/dos/how-do-i-get-the-certificate-of-authenticity-number-in-dos/4017.html

Renaming files with a batch script www.computing.net/answers/dos/renaming-files-with-a-batch-script/13970.html