Page 1 of 1

Select file ordering under Windows

Posted: 2019-11-11T02:47:54-07:00
by whugemann
I would like to write a Windows solution that montages, say, 4 photos in 2x2 order to an image. This is easy to achieve with montage, I know.
The difficult thing is to let the user easily choose the ordering of the images:
  • If I use Windows SendTo, I have no control on the file ordering. My experiments show that the ordering is is cyclically alphanumeric, the filename where you dragged with the mouse being the first, the order in which the files were chosen being irrelevant (?).
  • I could easily order all of the filenames alphanumerically, but this would mean that users would have to rename the filenames in order to express their wishes.
  • A possible solution would be a 2x2 ordering of drag & drop controls that transfer the filesnames to the IM batch file in the desired order. But how could that be achieved most easily?
  • Any other ideas?
I know, this question is more about programming than about IM, but as I am not sure which tool to use, I can't pose the question in one of the subforums.

Re: Select file odering under Windows

Posted: 2019-11-11T06:23:52-07:00
by snibgo
Yes, when I send multiple files to a BAT script, they seem to be ordered alphabetically.

There are different possible methods for users to specify the order. For example:

1. Show a list of the four files to the user. The user can slide any filename up or down the list.

2. Or: The user sends the first file to a script, then the second to the same script, then the third and the fourth. The script accumulates the file names. When it has four, it does the montage, in that order.

Re: Select file ordering under Windows

Posted: 2019-11-11T07:09:48-07:00
by whugemann
1: This sounds like an idea, although "sliding" is impossible in a command box. But one could list the files with a numbering and ask the user to answer somthing like "1432".

2: You cannot really sent multiple times to the same batch script, Windows will run an new instance every time. But one could accumulate persistent information in a textfile and start the IM command only if it contains four lines (of filenames). Is that what you mean?

Re: Select file ordering under Windows

Posted: 2019-11-11T07:38:21-07:00
by snibgo
Option 1 could be done with just Windows tools. Show the current list, and prompt for the user to accept it or choose a number and whether to move it up or down. Not elegant, but possible. Or, as you say, type a new ordering such as "1432". Or a Window that allows "sliding", eg in a custom program, or perhaps some toolkit can provide this.

Yes, option 2 needs persistent information, eg in a text file, to maintain state knowledge.

Re: Select file ordering under Windows

Posted: 2019-11-11T09:43:55-07:00
by whugemann
OK, here is my tested solution:

Code: Select all

SETLOCAL EnableDelayedExpansion
CD %~p1
DEL slist.txt
DEL sfl.txt
:: Query sort order
FOR %%i in (%*) DO (
	SET /P A=Position %%~ni%%~xi =
:: Sort filenames
TYPE mlist.txt|SORT >> slist.txt
:: Strip off counter
FOR /F "tokens=2 delims=_" %%i IN (slist.txt) DO ECHO %%i>>sfl.txt
:: Search unused filename for montage
FOR /L %%i in (0,1,9) DO (
	IF NOT EXIST %~dp1\montage_%%i.jpg (
		SET FN=montage_%%i.jpg
		GOTO jump:
:: Montage
C:\Programme\ImageMagick\Montage @sfl.txt -auto-orient -tile 2x2 -geometry 800x600+16+16 -quality 90%% !FN!
Hopefully, somebody else can draw some inspiration from it ...