Windows batch file script to sort URLs?

Up vote 2 down vote favorite 1 share g+ share fb share tw.

I don't know how to describe further what I want to achieve but I hope the example below explains everything: I want this text

0
1
2
3
4
5
6
7
8
9
sorted this way
3
7
0
4
8
1
5
9
2
6
In other words, for this particular example (withe four of each fruit jpeg) I want to sort lines according to this manner: 1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, and so on. I hope you get what I mean. The text file always contains urls with the same number of every "fruit" picture.

There can't be six lemon jpg files and four guava jpg files. I hope you get what I what I mean. Windows batch-file cmd link|improve this question edited Apr 2 '11 at 3:00 asked Apr 2 '11 at 1:02techdaemon326 38% accept rate.

This is a programming task, not a question. Do you expect people to write the code for you? – Ilya Kogan Apr 2 '11 at 1:10 I thought a simple code will accomplish this task.

– techdaemon Apr 2 '11 at 1:13 It's probably a simple code if you do it in some high-level language like Python (although I'm not even sure about that). This is not a standard task. – Ilya Kogan Apr 2 '11 at 1:19 No, this is a very easy task.

Not a one-liner, though. Here's a hint: Take the first line and grep | wc -l to see how many there are of it. You say there have to be the same number of each, so now we know how many "units" there are.

Now uniq it to see what the unique lines are. Echo them out to a file "count" times, where "count" is the wc -l output from before. – drysdam Apr 2 '11 at 1:38 @Drysdam Can you write it please?

Please, I need it badly. – techdaemon Apr 2 '11 at 1:40.

Maybe something like this: @ECHO OFF SET origfile=urls. Txt SET c=1 SET skip=4 FOR /L %%c IN (1,1,%skip%) DO IF EXIST %origfile%. %%c DEL %origfile%.

%%c FOR /F "tokens=*" %%L IN (%origfile%) DO CALL :process "%%L" DEL %origfile% FOR /L %%c IN (1,1,%skip%) DO ( TYPE %origfile%. %%c >> %origfile% DEL %origfile%. %%c ) GOTO :EOF :process ECHO %~1>>%origfile%.

%c% SET /A c=c%%skip+1 The idea is to output subsequent lines to different files, repeating the sequence every 4 lines (and 4 is parametrised here actually, so you can easily change it), then concatenate those files under the original name.

Neat approach doing a modulo. – Naraen Apr 2 '11 at 16:00 Wow! Works just how I need it to work!

Thank you very much! @Andriy M – techdaemon Apr 3 '11 at 1:36.

Run this on your file. Algorithm as described in my comment above. #!

/bin/bash FILE=$1 FIRST=$(head -1 $FILE) COUNT=$(grep $FIRST $FILE | wc -l) LINES=$(uniq $FILE) for I in $(seq 1 $COUNT); do echo $LINES | tr " " "\n" done.

Unfortunately, I am looking for a windows batch script. :( – techdaemon Apr 2 '11 at 2:18 I revised my question. Can you read it again please?

– techdaemon Apr 2 '11 at 2:40.

You can tell sort where to start comparing: /+n Specifies the character number, n, to begin each comparison. /+3 indicates that each comparison should begin at the 3rd character in each line. Lines with fewer than n characters collate before other lines.

By default comparisons start at the first So if your URI prefix is always the same (which your comments indicated) you can just run the file through sort /+25 list. Txt /O:list_new. Txt which should sort it by file name, then.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions