Computer Hope

Microsoft => Microsoft Windows => Windows 10 and 11 => Topic started by: MIRKOSOFT on September 25, 2018, 06:02:00 PM

Title: How to copy path to folder/file by command line?
Post by: MIRKOSOFT on September 25, 2018, 06:02:00 PM
Hi!

I need to copy path of current folder and/or file in that folder by command line.

How to do it in Windows 10, Windows 3.11 and DOS?

Thank you for each help, reply, suggestion or comment.

Miro
Title: Re: How to copy path to folder/file by command line?
Post by: Salmon Trout on September 27, 2018, 09:42:54 AM
here's Windows XP onwards... highlight what you want to copy and press ENTER. It's in the clipboard.

(https://images2.imgbox.com/58/76/cSAOcrDz_o.jpg)
Title: Re: How to copy path to folder/file by command line?
Post by: MIRKOSOFT on September 28, 2018, 07:25:21 AM
This works not.
Output is always to named file.

For clipboard exist command CLIP - I tried to get help, but error is that command not exist. I know that can't to be used without parameters - where to get syntax?
Also - exist CLIP in MS-DOS 6.22 ?

And is possible to get path from any variable? Or other way?

Thank you.
Miro
Title: Re: How to copy path to folder/file by command line?
Post by: Salmon Trout on September 28, 2018, 09:25:02 AM
....
Title: Re: How to copy path to folder/file by command line?
Post by: BC_Programmer on September 28, 2018, 10:23:23 AM
How to do it in Windows 10

Windows 10: Clip

Code: [Select]
C:\>clip /?

CLIP

Description:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

Examples:
    DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.

in this case you could echo %CD%, or use dir /b as Salmon Trout indicated on the file, and redirect it to CLIP to copy the current directory to the clipboard.

Windows 3.11 has no documented user-accessible way of copying data from a command prompt window via a command to the Windows Clipboard (Of course, you can use the control menu to mark and copy text shown in the command prompt window). Programs that are aware of Windows can detect it and will be able to copy and paste to and from the Windows clipboard though.


MS-DOS itself has no concept of a clipboard- only applications do.
Title: Re: How to copy path to folder/file by command line?
Post by: MIRKOSOFT on September 28, 2018, 01:51:33 PM
Ok, thank you!

Now I can use it the way I wanted.

DOS can have replaced clipboard by file content - but only text.

Miro