Page 1 of 1

Rename and copy file path via file associations?

Posted: 29 Nov 2017 12:45
by andreasf
Hello,

I need some help automating a task and I'm half way through. I am using file associations with docx;pdf to automate the following:

1. Have an original docx file that I duplicate and edit
2. Print the docx file to pdf
3. Rename the edited and pdf files to a number (doesn't matter)
4. Move both files to .\Archive\*\<sometext>-*-<moretext>
5. Copy the file path of the pdf file to clipboard

Steps 1, 2 and 3 are manual and I want them to remain manual.
I've managed to do step 4 using file associations and ::rename but I have no idea how to do step 5 and searching for "file path" in the help files didn't help much.

Any help is appreciated.

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 12:50
by highend
Your step nr. 04 contains the file path that you're moving the files to, correct?
Then just use the script command

Code: Select all

copytext <the variable that contains the path>;
to copy the path to the clipboard

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 14:57
by andreasf
highend wrote:Your step nr. 04 contains the file path that you're moving the files to, correct?
Then just use the script command

Code: Select all

copytext <the variable that contains the path>;
to copy the path to the clipboard
I haven't set any variables, it's just a single line command. Do I need to do that?

Also, how can I separate/specify just the pdf file when I execute the operation on both files simultaneously?

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 15:05
by highend
Show the code you're using and give a real world example (real file & folder names)

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 15:17
by andreasf
highend wrote:Show the code you're using and give a real world example (real file & folder names)
I'm in folder C:\Dir, with an empty folder C:\Dir\Archive and a file C:\Dir\Template.docx

I manually duplicate the word file, rename to, let's say 123.docx, and export it as a pdf.

I now have three files in C:\Dir:

Code: Select all

C:\Dir\Template.docx
C:\Dir\123.docx
C:\Dir\123.pdf
I select both 123 (docx & pdf) files, Ctrl+Alt+Enter and choose the file association action:

Code: Select all

|"Archive" docx;pdf>::rename , '.\Archive\*\text-*'
Now I have these files:

Code: Select all

C:\Dir\Archive\123\text-123.docx
C:\Dir\Archive\123\text-123.pdf
This works fine, but I also want to automatically copy the *pdf's* file path to clipboard, with a single action, without having to go into its directory (because in real usage there are more nested folders to go through). I hope that helps.

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 15:41
by highend
Ok, thanks

Try this as your new file association:

Code: Select all

|"Archive" docx;pdf>::$base = gpc(gettoken(<get SelectedItemsNames |>, 1, "|"), "base"); $dst = "<curpath>\Archive\$base\text-"; rename , "$dst*"; copytext "$dst$base.pdf";

Re: Rename and copy file path via file associations?

Posted: 29 Nov 2017 17:20
by andreasf
highend wrote:Ok, thanks

Try this as your new file association:

Code: Select all

|"Archive" docx;pdf>::$base = gpc(gettoken(<get SelectedItemsNames |>, 1, "|"), "base"); $dst = "<curpath>\Archive\$base\text-"; rename , "$dst*"; copytext "$dst$base.pdf";
Amazing, worked like a charm - thank you!