Converting folder listings to text, for a pano project.

5 views
Skip to first unread message

John McAllister

unread,
Apr 15, 2010, 1:41:03 PM4/15/10
to hugin and other free panoramic software
 
When I produce image display websites, I need to provide the image file-name, width and height, as literal JavaScript arrays... like this...
 
["file.jpg",720,560], ...
 
How can I convert folder listings (Win) into a suitable, specifiable text representation?
 
I appreciate that this is a bit off subject, but I know that the Brains Trust has the answer that I need.
 
(My pano head is progressing very well and I've managed some neat, new ideas.)
 
Respect to the people of PanoLand...
 
John...

Erik Krause

unread,
Apr 15, 2010, 3:58:36 PM4/15/10
to hugi...@googlegroups.com
Am 15.04.2010 19:41, schrieb John McAllister:
> ["file.jpg",720,560], ...
>
> How can I convert folder listings (Win) into a suitable, specifiable text representation?

use imagemagick and a shell script.
identify -format "[\"%f\",%w,%h]\n" *.jpg
should give you the JS arrays, one per line. You can pipe this into a
text file using f.e.
identify -format "[\"%f\",%w,%h];\n" *.jpg > arrays.js

See http://www.imagemagick.org/script/escape.php for details on the
parameter syntax.

Depending on your windows version shell uses ANSI character set and
javascript will assume Unicode. So special characters like german
umlauts will be changed. If this happens you might want to read
http://ss64.com/nt/cmd.html

--
Erik Krause
http://www.erik-krause.de

Erik Krause

unread,
Apr 15, 2010, 4:21:54 PM4/15/10
to hugi...@googlegroups.com
Am 15.04.2010 21:58, schrieb Erik Krause:
> use imagemagick and a shell script.
> identify -format "[\"%f\",%w,%h]\n" *.jpg
> should give you the JS arrays, one per line. You can pipe this into a
> text file using f.e.
> identify -format "[\"%f\",%w,%h];\n" *.jpg> arrays.js

Sorry, I forgot: The aqbove syntax is for direct use on the command
line. If you use it in a batch script you must double all % characters:

...
identify -format "[\"%%f\",%%w,%%h];\n" *.jpg >arrays.js
...

John McAllister

unread,
Apr 15, 2010, 4:30:26 PM4/15/10
to hugi...@googlegroups.com
It is not so much that I need an all-singing-and-dancing image processor...
More that I just want to translate system folder listings into text.
 
Although I cut my IT teeth on DOS 4, i
s there an application that would help me with this, a bit more WYSIWIG?
 
I do actually understand the basic syntax that has been demonstrated, I assume it manages the comma seperators between array elements.
 
But this app is not quite what I am looking for... I think something more primitive, perhaps.

Erik Krause

unread,
Apr 15, 2010, 4:55:41 PM4/15/10
to hugi...@googlegroups.com
Am 15.04.2010 22:30, schrieb John McAllister:

> I think something more primitive, perhaps.

There isn't anything more primitive than a command line.

Oh, well, you can try to use Javascript, f.e. Windows Scripting Host
understands Javascript. Have fun ;-)

David Haberthür

unread,
Apr 15, 2010, 5:49:44 PM4/15/10
to hugi...@googlegroups.com

Hey John.
At work I swear on ImageMagick, I don't know how else I'd crop and convert 15'000 images in one go (that's not a typo!) :)
I'm also using TotalCommander [1] for general file handling.
TotalCommander has a bunch of plugins for Catloging files and general stuff [2]. Maybe you can coax the Catalog-Plugin to output what you want to a .txt-file, but I'd really suggest (as Erik) to install ImageMagick, fire up that DOS-console and start with his suggestion, it's not that complicated...

After you've installed it from http://is.gd/buwCo and use "Start" > "Run" > cmd you should be greeted with your well known DOS-window. Navigate to the folder with the images and enter:
---


identify -format "[\"%f\",%w,%h];\n" *.jpg > arrays.js

---
and you should have your desired list.

Habi

BTW: Thanks Erik for that tip, I didn't know this :)

[1]: http://www.ghisler.com/, shareware, but I got an site-license from the University...
[2]: http://www.ghisler.com/plugins.htm

Erik Krause

unread,
Apr 15, 2010, 6:06:16 PM4/15/10
to hugi...@googlegroups.com
Am 15.04.2010 23:49, schrieb David Haberth�r:
> identify -format "[\"%f\",%w,%h];\n" *.jpg> arrays.js
> ---
> and you should have your desired list.

Reading again I think it's actually
identify -format "[\"%f\",%w,%h]," *.jpg> arrays.js
what he wants :-)

However, to create websites I'd suggest using PHP (with GD).
getimagesize() returns (among others) the complete width and height
attributes for the IMG tag directly...

Bruno Postle

unread,
Apr 15, 2010, 6:25:00 PM4/15/10
to Hugin ptx
On Thu 15-Apr-2010 at 20:30 -0000, John McAllister wrote:
>It is not so much that I need an all-singing-and-dancing image processor...
>More that I just want to translate system folder listings into text.

A long time ago Microsoft had a tool called tweakui that you could
use to copy multiple filenames into the clipboard. I'm not sure if
this still exists.

--
Bruno

--
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to hugi...@googlegroups.com
To unsubscribe from this group, send email to hugin-ptx+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/hugin-ptx

voschix

unread,
Apr 16, 2010, 4:20:55 AM4/16/10
to hugin and other free panoramic software
John,

I had a similar problem when compiling text for control files for
WPanorama. I detected, more or less by accident, that I can print
lists of files with a variety of attributes, among them dimensions,
using [xplorer²] Lite (http://www.zabkat.com/x2lite.htm).
In its default configuration it does not show file dimensions. Go to
menu "view" > Select Columns, add "Dimensions".
In the active pane, highlight the files you are interested in
Copy the file list to clipboard using "Ctrl P" (not "Ctrl C")

Hope this helps

Volker

John McAllister

unread,
Apr 16, 2010, 5:39:35 AM4/16/10
to hugi...@googlegroups.com
Thanks...
Xplorer2 Lite does not enable the display of more than one column.
Also, the "P" commands are disabled.

John McAllister

unread,
Apr 16, 2010, 6:16:39 AM4/16/10
to hugi...@googlegroups.com
Well...
I've installed ImageMagick.
I'm completely baffled, I'm offered a grey window with very few options.
As for shell scripts... I can't even find the command line!?
Come to that, how am I supposed to specify the particular folder?
John

Erik Krause

unread,
Apr 16, 2010, 8:28:55 AM4/16/10
to hugi...@googlegroups.com
Am 16.04.2010 12:16, schrieb John McAllister:
> I've installed ImageMagick.
> I'm completely baffled, I'm offered a grey window with very few options.
> As for shell scripts... I can't even find the command line!?
> Come to that, how am I supposed to specify the particular folder?

Open a command window. cd to the desired folder. enter the command. ready.

If you have more work to do and if you ask nicely I write a batch script
for you where you can drop a folder on in explorer.

--
Erik Krause
http://www.erik-krause.de

John McAllister

unread,
Apr 16, 2010, 1:43:31 PM4/16/10
to hugi...@googlegroups.com
After I navigate to the required folder at the dos command prompt, am I supposed to invoke $magick> before I enter the string:-  identify -format "[\"%f\",%w,%h]," *.jpg>  myfile.txt--?
Or... does the app have its own command line?
Their website is comprehensive... but it is an IT disaster.
I am still baffled.
 

Erik Krause

unread,
Apr 16, 2010, 1:52:34 PM4/16/10
to hugi...@googlegroups.com
Am 16.04.2010 19:43, schrieb John McAllister:
> identify -format "[\"%f\",%w,%h]," *.jpg> myfile.txt--?
> Or... does the app have its own command line?

imagemagick should have installed the command line tools and set the
PATH variable such, that you can simply call them in any command window.
If you are in the folder c:\myimages you simply type the identify
command at the command prompt:

C:\myimages>identify -format "[\"%f\",%w,%h]," *.jpg >myfile.txt

If you get a not found error open a new command window and type PATH
(and enter) the path to imagemagick folder should be part of the output
string. If not you must enter it manually:
http://www.computerhope.com/issues/ch000549.htm

--
Erik Krause
http://www.erik-krause.de

John McAllister

unread,
Apr 21, 2010, 3:09:55 AM4/21/10
to hugi...@googlegroups.com
Erik,
 
Utterly awesome.
It worked first time (no need for the shortcut with .bat on desktop), and I added the newline.
I've accomplished four hours work in ten minutes, start to finish.
 
What a nice man!
 
Talk again soon.
 
John

michael crane

unread,
Apr 21, 2010, 5:06:31 AM4/21/10
to hugi...@googlegroups.com

On Thu, April 15, 2010 11:25 pm, Bruno Postle wrote:
> On Thu 15-Apr-2010 at 20:30 -0000, John McAllister wrote:
>
>> It is not so much that I need an all-singing-and-dancing image
>> processor... More that I just want to translate system folder listings
>> into text.
>
> A long time ago Microsoft had a tool called tweakui that you could
> use to copy multiple filenames into the clipboard. I'm not sure if this
> still exists.

to do this I type dir >dir.txt in the directory then use notepad ++ in
column edit mode ( press alt) to trim it.

mick

John McAllister

unread,
Apr 21, 2010, 4:27:07 PM4/21/10
to hugi...@googlegroups.com
Mick...
This sounds like a good suggestion but, it has to be properly expanded to be useable.
 
John

michael crane

unread,
Apr 22, 2010, 8:28:12 AM4/22/10
to hugi...@googlegroups.com
On Wed, April 21, 2010 9:27 pm, John McAllister wrote:
> Mick...
> This sounds like a good suggestion but, it has to be properly expanded to
> be useable.
I'm not sure I understand.
click on c:/windows/system32/cmd.exe
cd to c:/users/wheremyfilesare
type "dir >dir.txt"
dir.txt now has a listing of the contents of the directory but it has the
date time and size as well but everything is in a line vertically.
get notepad++ from http://sourceforge.net/projects/notepad-plus/
and open dir.txt with it.
there is the handy block editing mode which you get by holding Alt as you
move the mouse, using this you can quickly delete the extraneous stuff to
leave one file name per line.

Henri Chevallier

unread,
Apr 22, 2010, 9:49:20 AM4/22/10
to hugi...@googlegroups.com
On Thu, Apr 22, 2010 at 8:28 PM, michael crane <mick....@gmail.com> wrote:
type "dir >dir.txt"
dir.txt now has a listing of the contents of the directory but it has the
date time and size as well but everything is in a line vertically.
Well just add /B to only have the names, /A-D to not show directories...So no need for Notpad++ and its column mode, "dir /B /A-D > dir.txt" is enough.
I like adding shortcuts on files and/or directories, so that you can just right click and execute a bat or whatever...
Reply all
Reply to author
Forward
0 new messages