| Author |
Message |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Mon 06 Aug 2012, 03:29 Post subject:
quoting file paths from rox selection Subject description: Is there a way to automatically quote file paths pasted from rox into rxvt (or other terminal) |
|
I posted this to the rox tracker:
| Quote: | When file(s) are selected in rox filer, their paths are copied to the primary selection "clipboard".
For paths which contain spaces it would be much more useful if the paths were quoted. |
This was the reply:
| Quote: | Sometimes it's useful, sometimes it isn't. However, we provide the target
text/uri-list with the individual items, so the target application can make
a sensible choice (e.g. a terminal emulator might choose to insert quotes
around items containing spaces) |
And here is a quote from an old thread on the rox mailing list:
| Quote: | The main problem is pasting names into Open boxes, where you don't want
: any escaping.
Or into browser location fields, where you want different escaping
('%20' instead of '\ ') |
Does anyone know if it is possible to get any common terminal emulator to put quotes around each pasted "text/uri-list" file path? Perhaps using a perl extension for urxvt?
What about common text editors, do any of them have a feature to do this? Or a feature to put quotes or brackets around each line once they are already inserted?
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
musher0

Joined: 04 Jan 2009 Posts: 2209 Location: Gatineau (Qc), Canada
|
Posted: Sun 12 Aug 2012, 01:50 Post subject:
|
|
Hi, disciple.
I'm not sure this will answer your question, but here goes:
1) In a rox window, I highlight the file.
2) Then I right-click "rename".
3) Within that message box, the filename appears highlighted. I right-click "copy".
4) I open a rxvt terminal, and
5) do Shift-Insert from the keyboard. Then name of the file is copied in full.
6) I then add quotes manually at the beginning and end of the filename.
As for a perl extension for urxvt, I never succeeded in adding one... So I don't know if it would include that feature.
Would it not be more "economical" to perhaps create a bash script that would capture the filename in the copy buffer and process it with the requested quote signs before you do Shift-Insert? Just a thought.
Keep us posted, because this indeed would be a nice feature to have.
Best regards.
| Description |
Example of transfer of a filename with spaces in it. (To be read counter-clockwise from ROX window.) |
| Filesize |
43.35 KB |
| Viewed |
215 Time(s) |

|
_________________
"...l'industrie de l'informatique n'aura besoin que de très peu de temps pour ramener l'humanité aux dessins rupestres." (M. Goebbel, Order of the Command Line; [ma trad.])
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Sun 12 Aug 2012, 05:56 Post subject:
|
|
| Quote: | | I then add quotes manually at the beginning and end of the filename. |
That's easy enough when you just want to paste one path. I'm more interested in the situation where you select a large number of files and paste all their paths at once.
| Quote: | | Would it not be more "economical" to perhaps create a bash script that would capture the filename in the copy buffer and process it with the requested quote signs before you do Shift-Insert? Just a thought. |
I'm not sure exactly what you mean. You wouldn't want a bash script to process the primary selection every time it changes and set that as the new primary selection, because it would mean that any time you select text it would immediately be unselected again when the bash script steals the selection.
It may be possible to create a parcellite/gtkclipit action to process the clipboard (actions only work on the copy/paste clipboard, not the primary selection) and add the quotes. But when I last tried creating actions with them they seemed to automatically escape all the characters in the clipboard as if it was a url or html code or something.
I'm pretty sure it would be easy to create an action for wmcliphist to do it. Wmcliphist is a fantastic old clipboard monitor for windowmaker, which can run actions automatically when the clipboard or primary selection matches a specific pattern - e.g. you can create an action to automatically recognise urls and email addresses and put them into submenus in the history list. But I don't think there are any programs which can put windowmaker dockapps in a normal system tray. Maybe I should try and see if JWM can swallow dockapps though...
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Sun 12 Aug 2012, 05:58 Post subject:
|
|
| Quote: | Then I right-click "rename".
3) Within that message box, the filename appears highlighted. I right-click "copy". |
You shouldn't need to do this. Just highlight the file in Rox, then shift-insert or middle click in rxvt. It certainly works when Rox is in double-click mode, anyway...
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
Karl Godt

Joined: 20 Jun 2010 Posts: 2675 Location: Kiel,Germany
|
Posted: Sun 12 Aug 2012, 08:01 Post subject:
|
|
Just a thought, because i do not understand everything correctly.
Filenames with spaces are a somewhat ever occurance in (Puppy) Linux.
To cope with spaces in / p a t h / t o / f i l e n a m e . e x t
I came up with this in bash :
| Code: | #!/bin/bash
ARGs=`set |grep BASH_ARG`
NR=`echo "$ARGs" | grep BASH_ARGC|sed 's|^BASH_ARGC=(\[.*\]="||;s|")$||'`;N=$NR
Ps=`echo "$ARGs" |grep BASH_ARGV |sed 's|^BASH_ARGV=||;s|(||;s|)$||'`
Ps=`echo "$Ps" |sed 's|" \(\[[0-9]*\]="\)|"\n\1|g'`
echo "$ARGs"
echo "$NR"
echo "$Ps"
while read p;do
echo "$p"
((NR--))
param="${p#*=}"
eval parameters[$NR]="$param"
echo "${parameters[$NR]}"
done<<EOI
$(echo "$Ps")
EOI
echo "${parameters[@]}" |
|
|
Back to top
|
|
 |
Karl Godt

Joined: 20 Jun 2010 Posts: 2675 Location: Kiel,Germany
|
Posted: Sun 12 Aug 2012, 08:29 Post subject:
|
|
Another one :
| Code: | mkdir -p "/ pa th / to /"
touch "/ pa th / to / fi le na me . e xt"
echo "This is a text file." > "/ pa th / to / fi le na me . e xt"
echo "PARAMETER
$@
"
for item in $@ ;do
echo "$item"
[ -f "$item" ] && { FILE_NAME="$item";break; }
if [ "$FILE_NAME" ];then
FILE_NAME="${FILE_NAME} ${item}"
else
FILE_NAME="$item"
fi
echo "$FILE_NAME"
[ -f "$FILE_NAME" ] && break
done
if [ -f "$FILE_NAME" ];then #&& { FILE_NAME="\"${FILE_NAME}\""; echo "FILE_NAME=$FILE_NAME"; }
FILE_NAME="\"${FILE_NAME}\""
echo "$FILE_NAME : is a regular file"
else
echo "$FILE_NAME : is not a regular file"
fi |
( for /root/Choices/MIME-types/* )
( I don't know how to handle tabs )
|
|
Back to top
|
|
 |
Peterm321
Joined: 29 Jan 2009 Posts: 196
|
Posted: Sun 12 Aug 2012, 15:17 Post subject:
|
|
| disciple Today, at 05:56 wrote: | | That's easy enough when you just want to paste one path. I'm more interested in the situation where you select a large number of files and paste all their paths at once. |
I had a similar problem with emelfm2 file manager when I wanted a facility to copy the full path of the active selected file to the clipboard to save typing in a command window. I didnt need the facility to operate on multiple files, or use files with spaces. If I had files with spaces I ran a script to convert these to underscores. In emelfm2 a button can be set up and attached to a short script to store the full path into the clipboard.
In the case of Rox, it does seem that selecting a file or files does this automatically. Fine. Only one problem: it appears that Rox has hardcoded the delimiter of the filenames with a space, so selecting multiple files stores a space delimited list in the clipboard. This will be a problem if the filenames themselves have spaces.
One idea would be to reconfigure or recompile Rox to replace the space delimiter with some other unique character that is never used in filenames. Another way is to create a script that will take into account embedded spaces in filenames to try and reconstruct the true filenames. I coded this script as a beginning of a solution:
| Code: |
#!/bin/bash
filelist=""
newline="
"
echo -e "\n\nContents of clipboard \n\n"
xclipboard=`xclip -o`
#
for filename in $xclipboard ; do
if [ "${filename:0:1}" = "/" ] ; then
if [ ! -z "$filelist" ] ; then
filelist="$filelist\"" # closing quote for previous filename
fi
filelist="$filelist$newline\"$filename" # newline + opening quote
else
filelist="$filelist $filename" # filename with a space
fi
done
#
filelist="$filelist\""
echo -e "$filelist\n"
|
Basically the script takes contents from what Rox placed in the clipboard and uses a derivative of the FOR statement to break the space delimited names into individual files. Files that begin with / are treated as a normal filename, The previous file in the list, if it exists, has a closing quote added to it and a newline with openinq quote inserted into the list. The rest of the filename is added.
Files not beginning with a "/" are treated as a being part of a filename with one or more embedded spaces. A space is attached to the filename and the loop continues to examine the list, adding to this current filename unless it starts with a "/".
Obviously the script is not completely tested e.g files with mutiple consecutive spaces or that begin or end with a space but its a start. It may be also be a better if recoded in Perl or other programming language.
|
|
Back to top
|
|
 |
npierce
Joined: 28 Dec 2009 Posts: 634
|
Posted: Mon 13 Aug 2012, 10:04 Post subject:
|
|
| disciple wrote: | | What about common text editors, do any of them have a feature to do this? Or a feature to put quotes or brackets around each line once they are already inserted? |
I guessing that you've probably already tried this and are looking for something more automated. But I'll post this anyway in case I've guessed wrong.
In geany I check the box for Use escape sequences in the Replace dialog. Then I search for \n and replace with "\n"
(If its a long list Replace All makes it less tedious.)
Of course you still have to cut one " from the end of the file, and add one to the beginning.
|
|
Back to top
|
|
 |
|