Copy the name and/or path of selected files

Get help for specific problems
Posts: 7
Joined: 29 Sep 2024

vbn

I would like to copy the name of the selected files (and some other data) from the Overview panel. The right-click menu of the selected file(s) would be a meaningful place to have commands like these but unfortunately, they are not there:

- copy filename
- copy filename with full path
- copy filename with relative path (relative to the folder that I selected for comparison)
- copy directory of the file with full path
- copy directory of the file with relative path

Are these functions somewhere else or do they not exist? If they don't, can I ask for this feature, please?

(I would need the full path of the selected file for pasting it into the command line, etc.)
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

The only possibility I see would be to run a Compare, and then in the main menu use
Tools / Export file list
Posts: 7
Joined: 29 Sep 2024

vbn

Yep, this is what I also found.

Therefore, it seems that the feature I asked for is not a "where is this feature?" question but more like a "can I get this feature, please?" question.
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

This could be done by creating some small batch scripts and having them called using the "custom context menu" options in FFS. This is interesting... I may dive into this on my own. I will of course provide a solution if I do create it!
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

- copy filename
- copy filename with full path
- copy filename with relative path (relative to the folder that I selected for comparison)
- copy directory of the file with full path
- copy directory of the file with relative path vbn, 29 Sep 2024, 10:58
- DONE
- DONE
- NOT DONE
- DONE
- NOT DONE

The two that are not done are the ones that are requesting a relative path. I looked through both of these:
https://freefilesync.org/manual.php?topic=external-applications
https://freefilesync.org/manual.php?topic=macros
I did not find a documented macro that would provide this. I swear I've heard of a macro that gives you the path of the left/right. That could probably be used in combination with a full path to obtain the relative path. Or @Zenju could graciously add the macro(s) to get it directly
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

I've attached the three batch scripts that I have working so far. Here is a picture of my custom context menu settings in FFS also:
2024-10-01 17_33_39-Options.jpg
2024-10-01 17_33_39-Options.jpg (119.35 KiB) Viewed 364 times
You will have to edit the commands to match wherever you store the scripts, of course. Here is the plaintext entries for easier copy-pasting:
Copy Directory Path
"J:\OneDrive\PC\Batch Files\FFS\Copy Directory Path.bat" "%parent_path%"
Copy File Name with Path
"J:\OneDrive\PC\Batch Files\FFS\Copy File Name with Path.bat" "%item_path%"
Copy File Name
"J:\OneDrive\PC\Batch Files\FFS\Copy File Name.bat" "%item_name%"
NOTE: When FFS calls these commands, no CMD window will show up! This tripped me up while testing since I was expecting the script to show up visually as if I ran it manually.

NOTE #2: Never trust random scripts from strangers on the internet! Right-click on the batch scripts and click 'edit' to see what they contain. They are very simple
Attachments
Copy File Name.bat
(65 Bytes) Downloaded 46 times
Copy File Name with Path.bat
(65 Bytes) Downloaded 57 times
Copy Directory Path.bat
(65 Bytes) Downloaded 48 times
Posts: 1038
Joined: 8 May 2006

therube

Shouldn't Open with default application be something like:

START "" "%item_path%\%item_name%"

(I didn't test that.)
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

Shouldn't Open with default application be something like:

START "" "%item_path%\%item_name%"

(I didn't test that.) therube, 02 Oct 2024, 15:22
I'm guessing not because that's the default set by Zenju and it works ¯\_(ツ)_/¯
Posts: 7
Joined: 29 Sep 2024

vbn

Thank you, xCSxXenon, I will try it as soon as I need it the next time. I really appreciate your efforts.
User avatar
Site Admin
Posts: 7211
Joined: 9 Dec 2007

Zenju

This could be done by creating some small batch scripts and having them called using the "custom context menu" options in FFS. xCSxXenon, 30 Sep 2024, 17:20
There is no need for scripts! Copying to the clipboard can be done directly, see the example in: https://freefilesync.org/manual.php?topic=external-applications
echo %item_name%| clip

echo %item_path%| clip

echo %parent_path%| clip

And if you need the full path, you can simply select a few rows and CTRL + C.
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

This could be done by creating some small batch scripts and having them called using the "custom context menu" options in FFS. xCSxXenon, 30 Sep 2024, 17:20
There is no need for scripts! Copying to the clipboard can be done directly, see the example in: https://freefilesync.org/manual.php?topic=external-applications
echo %item_name%| clip

echo %item_path%| clip

echo %parent_path%| clip

And if you need the full path, you can simply select a few rows and CTRL + C. Zenju, 25 Oct 2024, 14:48
Ok, so I definitely tried that but it was giving me errors when testing with files that contained spaces. It would only give me the text up to the first space. To fix it, I encapsulated the variable with double quotes and then used the script to remove those quotes to my liking. Today, your suggestion worked flawlessly. I don't know what, but I clearly had some error previously giving me grief.

I'm sure you have equally easy commands for the other two requests pertaining to relative paths? ;)
Posts: 1038
Joined: 8 May 2006

therube

when testing with files that contained spaces. It would only give me the text up to the first space
That happens when using a batch file, but not when the echo is placed directly as a parameter in the FFS dialog box.

For a batch file you would need something like
@echo off
set name="%1"

Not sure in what context you mean "relative", but...

go.bat:
FOR  %%I in (%*) do ( echo %%~pnxI | clip )
With that:
C:\LIB\NETT\FF\OLD\Firefox Setup 101.0.exe
becomes
\DEV\BACKUP\FreeFileSync\101.0.exe
(removing the drive part)


Check out FOR /?
User avatar
Posts: 4056
Joined: 11 Jun 2019

xCSxXenon

when testing with files that contained spaces. It would only give me the text up to the first space
That happens when using a batch file, but not when the echo is placed directly as a parameter in the FFS dialog box.
Correct, which is why I said clearly something was wrong when it wasn't returning the expected values.
Not sure in what context you mean "relative", but...
The context of the OP. It would return the path of the item relative to the root left or right location in FFS.
User avatar
Site Admin
Posts: 7211
Joined: 9 Dec 2007

Zenju

There is no need for scripts! Copying to the clipboard can be done directlyZenju, 25 Oct 2024, 14:48
Let me clarify this, because I think this is a nice feature that nobody really knows about:

The custom commands of the FFS context menu are directly evaluated by cmd.exe just like the contents of a cmd/bat file!

So they are in fact identical to one-line scripts! They can, but don't have to start another process.
The effect is the same as if you'd enter a line on the command line.

E.g. You can try the following to see the result of "echo" evaluated by FFS:
Description: "Hello World"
Command line:
echo hello world! & exitcode 42