1

Imagine I copied several files in Nautilus to paste them somewhere else; how could I obtain the list of copied filenames to, for example, use it in a script?

1

File paths marked for copying in Nautilus are automatically passed to the clipboard. You should be able to paste the paths in a text editor of your choice without any problem.

If you want to process the files in a terminal window you will have to select Paste Filenames in the right-click context menu.

Another way to pass file paths as arguments from Nautilus is to simply drag and drop the selected items into the terminal. The paths will automatically be quoted and escaped correctly.

As far as scripts are concerned: Utilities like xsel (install with: sudo apt-get install xsel) allow you to programmatically parse clipboard contents, if that's what you are asking for. To get the contents of the clipboard you can use xsel -b, e.g.:

for i in "$(xsel -b)"; do
  echo "$i"
done
  • Thats it! xsel is my answer. Thank you so much. I wish i could upvote but sorry i can't. – Nowruz Aug 17 '14 at 10:31
  • @MohsenNowrouzi Glad you found your answer. Don't worry about the votes. It's way more important to me that I was able to help! – Glutanimate Aug 17 '14 at 10:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.