0

Very often I grep and find through directories (usually containing images) and I have to "visually" check the result before I can operate on the result (like deleting, moving, etc). E.g.:

find ./pictures -iname "*.jpg" -size +2M -not -path "*/holiday/*"
path1/img_2345.jpg
path1/img_2346.jpg
path1/img_2347.jpg

I'd then like to quickly check what's behind the file names. I know I can just display them but sometimes I need to handle output of several hundred file names so running one command each is not an option.

nautilus / nemo etc. aren't an option neither because their filter capabilities are too limited (I'd really like to use find and grep)

So now my question is: Is there a way to comfortably use the output of arbitrary command line tools as input for a file/image viewer?

Edit: the comments show that I missed some details which are important to me:

  • The viewer should operate on the actual files rather than copies or symlinks (like e.g. gwenview does when you provide files on command line). The reason is I'd like to be able to delete/rename/move the files.

  • The involved viewer should keep the information about the directory structure (for several reasons)

    • operating on files becomes difficult when I only have the name
    • sometimes the file name is not unique
    • sometimes the directory name contains important information

I started to implement a tool on my own but I have that dirty feeling of reinventing the wheel.. at least I can better show you what I'm talking about:

enter image description here

Obviously in the bottom field you can write any command, file names are listed in the left field. Clicking on any list item would display it.

I guess this functionality could already exist as a plugin for a terminal emulator or a file manager - but I don't know any..

Until I find a better solution I will continue development (join me here). But I'd really like to save the time and use an existent solution.

How is your work flow?

  • 1
    Did you try to use something like gwenview $( find ./pictures -iname "*.jpg" -size +2M -not -path "*/holiday/*" )? Of course you can use some other viewer instead of gwenview. That's just an idea. You may want to quote"" the output to manage eventual spaces, or to filter through awk. In general it is not a good idea to parse the output of ls... but for quick solution it can works. Better to do a script and create a series of symbolic link in a temporary directory that you can delete exiting from the viewer. – Hastur Apr 30 '16 at 10:52
  • @Hastur: I tried this but this approach has two disadvantages: it doesn't scale well with a big amount of files returned by the shell command and you usually loose the directory context (no way to operate on containing directories etc.) – frans Apr 30 '16 at 10:58
  • And in particular gwenview will create a folder containing all files provided on command line - so there is no way to operate on these files any more.. – frans Apr 30 '16 at 11:08
  • Try to be more clear: your question was "So now my question is: Is there a way to comfortably use the output of arbitrary command line tools as input for a file/image viewer?" That is $(...). You can still copy or modify the files. If you have specific needs you should say it to economize time. You can always reproduce that behaviour with a script and, e.g. do the list of ln -s, run the viewer, operate as you want, exit from the viewer, do other actions as to delete the original file if the link is not anymore present ... there are many other way to do it all with their backsides. – Hastur Apr 30 '16 at 11:17
  • 1
    Using find's -exec or xarg, you could create a symlink to all files fulfilling the condition into a directory. Then you can easily cd to that directory and review the images with almost any viewer you like or even nautilus. – Gombai Sándor Apr 30 '16 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.