Hi All,
I have been beating my head against a wall and need some assistance or at least a shove in the right direction. I have a feeling the solution is easy, but I am too close to the situation and not able to see the answer clearly.
I have two buttons in DOpus I use to version files, more specifically I use it to version the selected file:
[ul]
First button will rename an existing file (ex "foo.txt" becomes "foo-20061101.txt") -- This works great...thanks to this message board for help in creating.
Second Button should take a file and copy it to a new name while preserving the original file (ex. "foo.txt" should be copied to "foo-20061101.txt", but "foo.txt" should also remain). -- This is not working.
What happens is that instead of having "foo.txt" copied to "foo-20061101.txt", "foo.txt" is copied to "foo.txt-20061101". Because of where the date is appended I loose my extension and the ability to easily review past documents
copy DUPLICATE AS="* - {date|yyyymmdd}.*"
[/ul]
Any Thoughts or suggestions?
Part of what makes the button I mention in #1 so powerful is the ability to use RegEx and the PATTERN parameter. However from what I can tell in reading the manual and looking through the resource center, it does not appear as though there is an easy way to use RegEx in conjunction with the COPY command.
- Does anyone have any thoughts on how would I take a file and create a copy of it and still preserve the file extension?
thanks!!
btw. DOpus Developers....keep up the great work! This app rocks!
Apart from doing a copy and then a rename, I can't think of a good way to do this.
The problem is that there's currently (to my knowledge) no way to specify the "old name" pattern, . in this case, as part of the command, so the wildcards in the AS string don't have anything to match.
You can specify the old name pattern when using the GUI, but not from the command-line.
I've just filed a feature request with GPSoftware asking them to add an OldName argument or similar.
By the way, you can specify FILE=. and this works... a little too well. If you specify a wildcard with the FILE argument then the Copy command ignores which files are selected and copies all files that match the wildcard. (Which is very useful in many cases, but not so good here.) In this case the result is a button which copies all files in the current directory to dated versions. I doubt you want that.
If you're comfortable using a batch file helper, you should be able to do this. First create the batch file, in my example here I gave it the fully qualified name of:
D:\Mine\cmd\Opus Duplicate and Rename.bat
and the sole contents of that batch file is the next line:
dopusrt /cmd copy %1 DUPLICATE AS "%~n1-%2%~x1"
Then for your Opus button code use the next two lines:
runmode hide
"D:\Mine\cmd\Opus Duplicate and Rename.bat" {f} {date|yyyyMMdd}
Of course you would need to change the fully qualified name of the batch file I used to the name you give your batch file.
I'll be happy to. The quickest source of that information should be right inside your computer. Just goto:
START/RUN, type in CMD then in the "DOS" box that pops up next, type in
FOR /?
And press ENTER.
You should see some general help for the FOR command iterator, but what you'll want to see will be near the bottom of the text. So keep pressing the spacebar (or any key) until you see the following:
%~I - Expands %I removing any surrounding quotes (")
%~fI - Expands %I to a fully qualified path name
%~dI - Expands %I to a drive letter only
%~pI - Expands %I to a path only
%~nI - Expands %I to a file name only
%~xI - Expands %I to a file extension only
%~SI - Expanded path contains short names only
%~aI - Expands %I to file attributes of file
%~tI - Expands %I to date/time of file
%~zI - Expands %I to size of file
The help uses a variable called %I% in their examples, whereas I used the two parameters the Opus button sent to the batch file. The first Opus parameter {f} represents the fully qualified file name of the file you have selected in Opus. The second Opus parameter in the button {date|yyyyMMdd} is the current date as formatted by Opus. In the batch file the first parameter passed to it {f} is represented by %1 while the second parameter passed to it {date|yyyyMMdd} is represented by %2.
Using the above output of the FOR help as a reference, you can see that if you use %~n1 the fully qualified file name that Opus sent to the batch file will be changed to only the file name with no path, file extension, or quotes. And likewise %~x1 would represent only the file extension of the fully qualified file name sent to Opus. In other words, this:
"%~n1-%2%~x1"
Means this:
"File name only-opus formatted date.file extension"
If you want more information on this, I'd recommend the book called "Windows NT Shell Scripting" by Tim Hill.