Rename and copy file path via file associations?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
andreasf
Posts: 16
Joined: 29 Nov 2017 12:37

Rename and copy file path via file associations?

Post 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.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename and copy file path via file associations?

Post 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
One of my scripts helped you out? Please donate via Paypal

andreasf
Posts: 16
Joined: 29 Nov 2017 12:37

Re: Rename and copy file path via file associations?

Post 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?

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename and copy file path via file associations?

Post by highend »

Show the code you're using and give a real world example (real file & folder names)
One of my scripts helped you out? Please donate via Paypal

andreasf
Posts: 16
Joined: 29 Nov 2017 12:37

Re: Rename and copy file path via file associations?

Post 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.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Rename and copy file path via file associations?

Post 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";
One of my scripts helped you out? Please donate via Paypal

andreasf
Posts: 16
Joined: 29 Nov 2017 12:37

Re: Rename and copy file path via file associations?

Post 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!

Post Reply