How to select files inside a ROX window by a bash script?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
R-S-H
Posts: 487
Joined: Mon 18 Feb 2013, 12:47

How to select files inside a ROX window by a bash script?

#1 Post by R-S-H »

Hi,

I want to select different files (sorted in a predefined list) shown in a previous opened ROX filer window from within a bash script.

Is this possible, and how?

Thanks,

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#2 Post by seaside »

R-S-H,

I haven't tried this but perhaps something could be done with the SOAP feature of rox.

http://rox.sourceforge.net/Manual/Manua ... .html#soap

Maybe this part - "Copy(From, To, [Leafname, Quiet]) Copy each file in the array From to the directory To........"

Regards,
s

R-S-H
Posts: 487
Joined: Mon 18 Feb 2013, 12:47

#3 Post by R-S-H »

Hi seaside.

Yeah, I've found already an example for this in a script of your SFS-Exec (the script that opens ROX filer showing only the SFS files in SFS directory)

Option 'Filter' or ?'Filters'? unfortunately seems not to be able to filter a list of files (except *.sfs etc. - but that would show all of the .sfs files).

I thought about to filter about 35 files from a directory that contains about 800 files. Would have been nice to get a ROX filer window opened with an preselected selection of different files.

However, thanks for your reply to this.

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#4 Post by seaside »

R-S-H,

I'm not exactly sure what you have in mind. A group of user-selected files or preselected? At any rate, one more idea-

Perhaps you could us bash/find to select and copy files to NEWDIR directory and then open it "rox -d NEWDIR".

Regards,
s

User avatar
Rattlehead
Posts: 368
Joined: Thu 11 Sep 2008, 11:40

#5 Post by Rattlehead »

Not the neatest way to do it, but you could also 'robotize' the whole process with Xdotool, making a loop that goes

pick first item on the list
keypress / in Rox
type the file name
keypress / again
keypress space
(end of loop)

The whole selection process will then happen 'in your face', which can be regarded as lame or sci-fi-like, depending on the situation I guess :?

Also, it depends on the number files you usually want to select. The typing is not instant, so if the amount is big...

Just an idea

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#6 Post by amigo »

Don't mix cli and gui together -what you propose is a bad idea. Just use nice shell to do what you want...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#7 Post by sunburnt »

Trying to get info. from GUI`s that aren`t designed for it is pointless.
Geany, rxvt, GtkDialog, etc. With rxvt you can redirect some output to a file.
You can`t scrape Geany`s edit box for text, you can only read it`s files.
But if Geany`s file is not saved... Then the file`s not up to date.

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#8 Post by nilsonmorales »


User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#9 Post by tallboy »

R-S-H wrote:...shown in a previous opened ROX filer window
Hmm. I am not sure if I interpret your wish correctly, but I think this can be done with an ordinary redirection command in Linux.

If you open /root/my-documents/ , and then make a text-file and save it to my-documents, it will be visible at once in the open window.

In a script, you can redirect the files you find with 'grep', 'find' or whatever technique you use, with:

Code: Select all

find files | mv /root/my-documents
Test it with this command in a terminal:

Code: Select all

touch 1.txt 2.txt 3.txt | mv my-documents
The mv -t or --target-directory option can be used:

Code: Select all

touch 1.txt 2.txt 3.txt | mv --target-directory=my-documents
See mv --help for options.

Sorry if I misunderstand completely, then we just try again! :D

THIS IS NOT WORKING WITH THE CODE SUPPLIED; REGARD IT AS INSPIRATION ONLY!

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Re: How to select files inside a ROX window by a bash script?

#10 Post by musher0 »

R-S-H wrote:Hi,

I want to select different files (sorted in a predefined list) shown in a previous opened ROX filer window from within a bash script.

Is this possible, and how?

Thanks,

RSH
Hi, R-S-H.

Maybe you will find some leads in the ROX manual, chapters 10 and 14, and also Annex C. Those parts of the ROX manual focus on searching and displaying, and how to script ROX directly (Annex C).

Your project is a little vague in my mind, but a "previous opened ROX filer window" is a directory, no? Same as
ls <directory>.
So maybe you can forget ROX and do it with ls ?
(Depending on what you want to do, fo course)

Something like
ls [directory]/[flag_for_search] > list.lst
then do something with the list with the
for...do command ? (copy, display or link, etc.)

The full less utility can be handy because it has the ![command] function from the display.

Just my 2 cents. :) Good luck!

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

R-S-H
Posts: 487
Joined: Mon 18 Feb 2013, 12:47

#11 Post by R-S-H »

Hi.

Thanks for all the replies.

Since a picture is telling more than a 1000 words - this how the ROX filer window should look like, when opened by a script (as an example).

The files are listed in a text file. I just need to either deselect a few files manually or to add a few files to this selection manually.

I've already thought about any use of xdotool for this, but can't see any solution how to tell xdotool to select a specific file in a ROX filer window.

RSH
Attachments
image-3.jpg
(108.5 KiB) Downloaded 585 times
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#12 Post by tallboy »

BTW, the Linux commands available in puppy, are not the full versions, but limited versions from Busybox. It is possible that a perfectly valid Linux command string will not give the intended results, when used in puppy.

For a full set, you must download and install 'coreutils', but be prepared for some strange results if the old commands are not completely removed. Busybox (or maybe X) may crash.

Take a look at this link for some versions of code:
http://www.cyberciti.biz/tips/howto-lin ... -file.html

tallboy
True freedom is a live Puppy on a multisession CD/DVD.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#13 Post by MochiMoppel »

I know, it's an old thread, but it's not yet solved so I hope it's OK to give it a shot.

The challege - as I understand it - is to select files in a ROX-Filer window programmatically.
R-S-H wrote:The files are listed in a text file
OK, that's clear.
I just need to either deselect a few files manually or to add a few files to this selection manually.
Less clear, but probably not relevant. I guess that this is something you want to do after your script selected the files
I've already thought about any use of xdotool for this
I can't think of anything else. ROX itself provides no way to select/deselect files programmatically.
but can't see any solution how to tell xdotool to select a specific file in a ROX filer window.
See below. This works for me.

The script reads file paths from a text file (each file path there on a separate line), then opens a ROX window and selects these files. I hope that this is what you asked for.

Code: Select all

#! /bin/bash
FILES="/tmp/01TEST
/tmp/abTEST
/tmp/cdeTEST"

touch $FILES                                # Create some test files
LIST="/tmp/00_filelist.txt"                 # Assign variable LIST
echo  "$FILES" > "$LIST"                    # Write file paths to file LIST 

FIRSTFILE=$(head -n1 "$LIST")               # Retrieve first file path  in LIST
rox -s "$FIRSTFILE"                         # Open ROX-Filer with FIRSTFILE activated (but not yet selected)
xdotool key question                        # Shortcut '?' opens the 'Select If' entry field
xdotool type "system(grep "%" "$LIST")" # Define  grep command
xdotool key Return                          # Run command. ROX selects all files matched in grep command
Please note that the ROX-Filer system command may be named differently, depending on locale. Use the little help button, left of 'Select If', to check the appropriate syntax.
Attachments
ROX-Filer_selection.png
(34.31 KiB) Downloaded 349 times
Last edited by MochiMoppel on Thu 19 Oct 2017, 02:33, edited 1 time in total.

arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

#14 Post by arivas_2005 »

Hello
I need filter many files
Rattlehead wrote:Not the neatest way to do it, but you could also 'robotize' the whole process with Xdotool, making a loop that goes

pick first item on the list
keypress / in Rox
type the file name
keypress / again
keypress space
(end of loop)

The whole selection process will then happen 'in your face', which can be regarded as lame or sci-fi-like, depending on the situation I guess :?

Also, it depends on the number files you usually want to select. The typing is not instant, so if the amount is big...

Just an idea
I found this but it does not work for me
( nothing happens when you press space or wiht enter always comes the list of sfs)
I need to filter only txt or jpg etc

arivas_2005
Posts: 212
Joined: Sun 25 Feb 2007, 14:39

#15 Post by arivas_2005 »

:oops: :oops: :oops:
Shift+/ is shortkey of 'goto' command.
that's why I did not get the result

:idea: I proceeded to create a shortkey for option
right click, display, filter files whit Shift + 8 and
ready
. Its Works!
need met!

Post Reply