My use case is typically to open a directory with images in sxiv, and then to rename using the following key-handler script:
"w")
name="$(dmenu -p "Rename $file to: ")" 2> /dev/null
ext="$(echo "$file" | sed -r "s/^.*\.(.*\$)/\L\1/" | dmenu -p "Use extension as: ")"
if ! [ -z "$name" ]; then
mv "$file" "$(dirname $file)/$name.$ext"
fi ;;
This removes the image from the set (no longer visible in thumbnails). If I add a & before the ;;, it keeps the image there, but under the old name. This is especially a problem if I want to re-rename it (made a mistake), as the above script wouldn't find the new file name.
I'm wondering if anyone has implemented a solution where it reloads the directory (or set of images I'd loaded in with the original command) under its new name.
]]>Hi,
I have a newbie question here.
I cannot get sxiv to open jp2 files.When I use sxiv in the command line to open jp2 files I get the following:
sxiv: ./Downloads/509893-Color In Business, Science And Industry_jp2/509893-Color In Business, Science And Industry_0425.jp2: Error opening image
sxiv: no more files to display, abortingthanks
Actually, it looks like sxiv doesn't support jp2 files. You would need to convert the files to another format first to view them with sxiv. For example, you can install imagemagick:
sudo pacman -S imagemagick
And then convert the file with its convert script (note the "jpg" extension in the second argument):
convert "509893-Color In Business, Science And Industry_0425.jp2" "509893-Color In Business, Science And Industry_0425.jpg"
And then open the jpg result with sxiv:
sxiv "509893-Color In Business, Science And Industry_0425.jpg"
'hope that helps!
]]>Hi,
I have a newbie question here.
I cannot get sxiv to open jp2 files.When I use sxiv in the command line to open jp2 files I get the following:
sxiv: ./Downloads/509893-Color In Business, Science And Industry_jp2/509893-Color In Business, Science And Industry_0425.jp2: Error opening image
sxiv: no more files to display, abortingthanks
just to check: Did you not use quotes around the file path? If not, try:
sxiv "./Downloads/509893-Color In Business, Science And Industry_jp2/509893-Color In Business, Science And Industry_0425.jp2"
I have a newbie question here.
I cannot get sxiv to open jp2 files.
When I use sxiv in the command line to open jp2 files I get the following:
sxiv: ./Downloads/509893-Color In Business, Science And Industry_jp2/509893-Color In Business, Science And Industry_0425.jp2: Error opening image
sxiv: no more files to display, aborting
thanks
]]>I am not complaining... just wondering.
]]>I really need to study the man pages a bit more to end up with the most simple and fastest command line... I didn't know about the `-i` option of sxiv either.
My final line now is:
find . -type f -iname '*.jpg' -not -iname '*.lzn.*' | sxiv -ifbt
But now I wonder if any kind of sorting could be implemented... most of my file organization is like so:
YYYY/YYYY-MM-DD - <camera> - <text>/<camera>-<roll>-<img-no>.jpg
(I shoot mostly film and use a few different cameras, in case you wonder about "roll" and "camera".)
`find` and `sxiv` don't have a sorting option as far as I can see, so piping the find output through sort would be the only option:
find . -type f -iname '*.jpg' -not -iname '*.lzn.*' | sort | sxiv -ifbt
That works...
I already wrote a little script that allows me to just view images of a certain camera; I think I will expand on that to include displaying images from a certain year.
OK, enough of that, not sure if this is the right place to discuss these kinds of scripts, which are not 100% sxiv related.
]]>That is why I used the `tr` command... I am not sure if I could achieve the same without?
Yes, it is possible, for example:
find . -type f -iname '*.jpg' -not -iname '*.lzn.*' | sxiv -i
drtebi wrote:Loving sxiv, since the first run.
Today I needed to search for an image. Rather than going through each directory etc., I figured there must be some command-line trick.
This is what I came up with:
find . -type f -name '*jpg' | tr "\n" "\0" | xargs -0 sxiv -qfbt
It searches for images in the current directory and all sub-directories, then opens sxiv in thumb view with the results.
I am sure there are smarter ways to do this, but this worked for me.
You definitely want the -print0 instruction to find. Also, usually -iname is safer (some files may be named JPG and won't be found by your -name search)
find . -type f -iname "*.jp[eg]" -print0 | xargs -0 sxiv -qfbt
I also changed the expression so it finds '.jpe' files as well; it still can't find .jpeg.
For complete accuracy, consider using -iregex instead of -name / -iname; it will allow to find -all- jpegs (.jpg/.jpeg/.jpe) . A quick test suggests that "-iregex '.*.jp[eg]g?'" is correct.
...
All that said, are you aware of sxiv's `-r` option? It's usually fine, if you simply want all images in a directory. Non-images are automatically filtered out. The only thing to beware of is that large video files take sxiv a long time to detect as 'not an image'.
Thanks for these great tips!
The jpeg/jpe/jpg option is not really a concern for me, I have made sure to always rename all images to .jpg.
Regarding the '-r' option, that would not work for me, because I actually have to filter out images that have "lzn" in their filename. These are created by LightZone, the image editor I have been using (they are small preview files with embedded processing instructions for LightZone). Currently I simply filter them out with `grep -v`. Thus my actual `find` line is:
find . -type f -name '*jpg' | grep -v ".*lzn.*jpg$" | tr "\n" "\0" | xargs -0 sxiv -qfbt
That is why I used the `tr` command... I am not sure if I could achieve the same without?
]]>Loving sxiv, since the first run.
Today I needed to search for an image. Rather than going through each directory etc., I figured there must be some command-line trick.
This is what I came up with:
find . -type f -name '*jpg' | tr "\n" "\0" | xargs -0 sxiv -qfbt
It searches for images in the current directory and all sub-directories, then opens sxiv in thumb view with the results.
I am sure there are smarter ways to do this, but this worked for me.
You definitely want the -print0 instruction to find. Also, usually -iname is safer (some files may be named JPG and won't be found by your -name search)
find . -type f -iname "*.jp[eg]" -print0 | xargs -0 sxiv -qfbt
I also changed the expression so it finds '.jpe' files as well; it still can't find .jpeg.
For complete accuracy, consider using -iregex instead of -name / -iname; it will allow to find -all- jpegs (.jpg/.jpeg/.jpe) . A quick test suggests that "-iregex '.*.jp[eg]g?'" is correct.
...
All that said, are you aware of sxiv's `-r` option? It's usually fine, if you simply want all images in a directory. Non-images are automatically filtered out. The only thing to beware of is that large video files take sxiv a long time to detect as 'not an image'.
]]>Today I needed to search for an image. Rather than going through each directory etc., I figured there must be some command-line trick.
This is what I came up with:
find . -type f -name '*jpg' | tr "\n" "\0" | xargs -0 sxiv -qfbt
It searches for images in the current directory and all sub-directories, then opens sxiv in thumb view with the results.
I am sure there are smarter ways to do this, but this worked for me.
]]>To give a little context, I am aiming to insert 'headings' in a list of images I'm organizing. So, user presses key, is prompted for string, image is constructed and should be inserted in file list.
Further context to that is that my fork of sxiv includes commands to rearrange the filelist, and an option to output entire filelist at exit, so this 'organising' is actually possible at all.
My current best candidate idea is that sxiv provides the name of a temporary file, and the filelist size, to the key handler, and the key handler can write any number of 'INDEX\nFILENAME' pairs to it (with index='' equalling current cursor pos, index=-1 equalling end of list, etc).
]]>Hi, just posting to ask about inserting files in the filelist at runtime. Personally, I have decided this is a necessity for dealing with larger filelists.
If you've implemented something like this, I'd appreciate hearing about it.
I rather think you should implement non-blocking stdin input that keeps adding files during the sxiv runtime when new data is available.
]]>Currently, I have one idea how to do this: A command that reads the clipboard content, and inserts files in the filelist at the current index.
This approach has a few wrinkles when used in conjunction with keyhandler script.
* Destroys the current clipboard content
* The insertion command following any insertion-orientated keyhandler command must be triggered by xdotool hackery, which is unreliable.
IME this is much easier for the use case where you are gradually narrowing down a list of images. And especially is not vulnerable to the 'f%*&, I forgot to select all before quitting, now my list is just empty...' mistake.
EDIT: Note that there currently seems to be an occasional bug with this, where images removed from the filelist are still output. Exactly what triggers it is unclear.
It could even be a bug with the following SpaceFM script I use to filter a filelist:
TMP=/tmp/sxivfilt.$$
sxiv -i -O < "$fm_file" > "$TMP"
# XXX there is still some problem with files removed from filelist hanging around.
# I think I need to trigger a check at exit, or something?
if [ -s "$TMP" ]; then
mv "$TMP" "$fm_file"
fi
but tbh, the above seems very simple.
]]>