Copy destination file to clipboard

I would like to make a button which would help me share my files on my server (localhost) very fast, so I want to:

  1. copy selected file(s) to specified dir (eg. c:\server) - done
  2. add it to specified collection (the copy, not the original file)
  3. put to the clipboard something like server.com/[filename] or just copy the new file (I know how to obtain file name when the file was copied to the clipboard).

First one is easy: COPY TO c:\server
What about 2 and 3?
Here is something that add to collection selected files. Is it possible to make it add files from another location? : Copy TO="coll://" CREATEFOLDER="Delete" COPYTOCOLL=member

I tried to think out and that's what I made:

Clipboard COPYNAMES=nopaths
Copy To s:_shared (Copy Move on button rightclick), s:\ is my virtual directory created using subst.

Plus my ahk code (it works on directories, too!)

#u:: KeyWait LWin Loop, parse, clipboard, `n { clip_tmp=%A_LoopField% If clip_tmp contains \ { StringGetPos, t_start, clip_tmp, \ ; Replace \ to / StringReplace, t, clip_tmp, \, /, 1 ; 1 - replace all t:=SubStr(t, t_start+2) } else t:=clip_tmp StringReplace, t, t, %A_Space%, `%20, 1 BlockInput On SendInput http://[address]/_shared/%t% BlockInput Off } return

By the way, Is it possible to get rid of an error when adding files already in a collection? I mean I use Copy TO="coll://" CREATEFOLDER="Selected" COPYTOCOLL=member and if a file is already in collection, there is an error. I would like it not to show (the file is in collection so there's no reason to worry).

Unfortunately, there is no way to avoid that error dialog at present. I filed an issue report with GPSoftware about this just yesterday. In that report, I suggested that the Copy dialog provide the same file collision options when copying to a File Collection as would appear when copying to a file system folder, namely: Skip, Skip All, Replace, and Replace All. I also requested that the Copy command respect the WHENEXISTS/O parameter, which is what you can use to proactively handle file collisions when copying to a file system folder. But currently, this option does nothing when adding (copying) files to a File Collection.

@BBTs See KA#00197

For what it is worth, I did try to work on a button for you. But I ran across quite a few Opus issues that stand in the way.

Maybe it's possible to delete all items in collection matching {filename} and then add the file to collection, when it's sure it's not already in it?

What do you mean by replace in terms of collections? If a file is already in a collection, there's no need to replace it. What could it do? The only option I find reasonable is skip, which should be default.
By the way, I would like collections to follow file movements. If I move a file that was added to a collection and move that file from c:\ to d:, I would like it to be still accessible from collection.

Maybe it's possible to delete all items in collection matching {filename} and then add the file to collection, when it's sure it's not already in it?

What do you mean by replace in terms of collections? If a file is already in a collection, there's no need to replace it. What could it do? The only option I find reasonable is skip, which should be default.
By the way, I would like collections to follow file movements. If I move a file that was added to a collection and move that file from c:\ to d:, I would like it to be still accessible from collection.

I'm not sure what meta data Opus stores inside of a File Collection entry for a file and what meta data it pulls from the underlying file each time that File Collection is listed as a folder. If a file I previously added to a collection has changed in anyway, it might be useful to re-add it to the collection to update any of its meta data. (I have no knowledge of the inner workings of a File Collection).

Even still, while there may not be a need to replace the item, this is more about a common look and feel to Opus. When you copy a file to a file system folder and a file collision occurs, you are prompted with a very intuitive information dialog that offers you options; it is not an error message. So the same general behavior should also apply when copying a file to a File Collection and a file collision occurs (perhaps with fewer options available); but it really should not be an error dialog.

The other reason I submitted a request was to provide a common means to suppress the file collision dialog altogether. Currently, you can prevent the dialog when copying to a file system folder, but not when copying to a File Collection. Making the two processes more similar lends itself to providing a similar means to proactively and optionally suppress the file collision dialog in the first place (the WHENEXISTS option).

While it may be true that there is only one viable course of action to take; it is not true to say that all users will (or perhaps should) want the dialog suppressed all the time. Some users may actually want to be informed that a file already exists in the File Collection.

This is feature request and you should submit it to GPSoftware (see link in my signature). I know Vista tracks and changes Windows shortcuts when the underlying file is moved by Windows Explorer in Vista. However, I'm not sure how difficult such a feature would be to add to Opus.

Sent as 360016125953.

This doesn't work
Delete REMOVECOLLECTION coll://Selected/{file$}
But when there's no removecollection switch, it 'works' but it tries to delete the real file. Can anyone help?

This is similar to one of the issues I encountered, while trying to make a button that did what you wanted. Only I was trying to use {file$} to add a files to a collection, and I noticed that if more than one file was selected, only the first was being added (at least how I constructed my test button). I'm still playing around with this, and I will be filing an issue report with some detailed test cases. I'll give the delete code you posted above and try it as well. It looks like the two are related (the one you found and the one I found).

This might be of interest for putting the URLs in tthe clipboard (if you don't need the image width/height then it can simplified a lot):

Copy IMG links to Clipboard with Width and Height

The script works quite good. Now I'm trying to make it work on directories too.
Could you explain how does it know it has to invoke Rename_GetNewName for each file? Is it possible to change the name of this function? I guess it's name is always the same for file renaming. What about buttons?

See here for a detailed explanation: [[OBSOLETE] "Abusing" Rename Scripts to do other things with file info)

You can turn those scripts into buttons. Some of the examples do that.

I didn't find this one before.
Thank you very much, it will help me make more scripts and automate my work. :slight_smile:

I found a way to make the script above work on directories too (by removing the part where it checked if width is not set).