Copy file path into clipboard by drag&dropping it into exe file - drag-and-drop

Is there any possibility to create exe file which copies path of a file into clipboard when you drag&dropp the file into the exe? How could I do it ?
Thanks

Two ways OTM in Windows:
1. Start > Run
2. Start > Run > "cmd"
in both cases, once you drag the file onto the window, its entire path will be pasted.
To do the copy, you'll have to do that manually (easier in the Run window)
To do this onto an application:
How do I drag and drop files into an application?

A just found a program called Copy Path that works for me. It adds "Copy path" to the Windows Explorer context menu (not exactly drag-and-drop, I know).

Related

VSCode Win Shortcut to Launch with Open Folder Command

I have 10 applications that I constantly work on. At times I need to open them all up separately to run bash commands on them. Is there a way I can create a windows shortcut for each folder, then I select all 10 shortcuts and click enter to initiate 10 different VSCode applications each opens up with their respective folder I set to?
(Windows 10) To open VS Code in desired directory using shortcut:
Create shortcut to Visual Code Studio app,
Right click on the shortcut and select Properties,
In Target field append your directory path (remember to use quotes " " if there are spaces in the path).
ctr + K + O
open a folder vs code most common shortcut key available all platforms same
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
I use a batch file like in Sean's solution. You can automatically close the terminal after launch if you use the start command rather than "code ."
Here's an example:
#echo off
cd "C:\path\to\your\project\folder\"
start "" "C:\Program Files\Microsoft VS Code\Code.exe" .
exit
Note: if you don's like how the batch file looks, you can make a shortcut to the batch file and change the shortcut's icon to the VS Code icon.
In a similar situation, I use a batch file to launch my most used vscode windows. I am not yet smart enough to make the cmd windows disappear after they open vscode, but maybe someday. In each batch file, use the following changing the directory for each project.
#ECHO OFF
cd C:\directory\where\your\project\is
code .
exit

Visual studio code, how to copy the file name

In the visual studio code, it has commands to Copy Path and Copy Relative Path (Ctrl+Shift+p->File: Copy Path of Active File). Is there a way I could copy the active file name instead of the whole path?
If there is no way copy the active file name. Is there a way I could write a script or something which creating a new command based on existing Copy Path and showing the new command in the Command Palette?
The extension Copy file name works like a charm!
CTRL+ALT+F gives you filename and CTRL+ALT+E gives the filename.extension.
open your file on vscode> select file as active file> Ctrl+Shift+P > Alt+Shift+C
now you can use Ctrl+V to paste this path any where you want.
step1. first install "copy file name" extension from extensions(ctrl+shift+X) in your vscode.
step2. then use ctrl+alt+e for copying the full file_name with file_extension(like .cpp or .py or .java etc..).
or ctrl+alt+f for for copying the file_name
without file_extension.
It is been a while but I found if you want to write a script using the currently opened file, create a new task in task.json and calling some scripts in the task might be a good option.
Basically, ${file}, ${fileBasename} and ${fileDirname} are the variables that can be used in your script file.
Useful reference:
https://code.visualstudio.com/docs/editor/variables-reference
As an alternative, if you see the active file in the "Explorer" view, you can type F2 once you select it.
With VSCode 1.71 (Aug. 2022), you can type F2 and:
1st press => prefix
2nd press => all
3rd press => suffix
4th press => cycles back around to prefix
This has been release to VSCode insider today, for you to test/play with it.
Without using any extensions, here's a combination of key shortcuts you can use to copy the path of the current file. It's a bit cumbersome but with some practice can be faster than doing the same using the mouse.
Ctrl+Shift+E to open and focus the Explorer pane.
The current file will be selected automatically by default.
F2 to start renaming the file.
This will select the file name without file extension.
(optional) Ctrl+A to include the file extension in the selection.
Ctrl+C to copy.
Escape to abort renaming (or just click anywhere).
no need any extensions, Ctrl+K --> Ctrl+Shift+C, then you will get relative path

Powershell -command text not appearing

Windows 10, Powershell -v 5.1
I have tried to restore powershell to defaults, both normally and as admin. I have changed/turned off high contrast settings, deleted console files for powershell in Regedit, as well as tried to restore defaults from command line scripts.
Have tried restarting after applying all of this, but much of my output text is invisible, as well as commands with only one "-" dash, but commands with "--" appear.
See in pics below
no - identifiers
Invisible "-i"
Reappearing "--i"
Invisible Surge Data
It sounds like you've persistently modified the console-window colors in a manner that renders certain syntactic elements invisible.
You can either modify your console-window settings interactively - which may be nontrivial - or you can try to restore the original colors by recreating
the shortcut files that start your console windows:
Shortcut files (*.lnk files) contain their own console-window settings, which are independent of the defaults defined for console windows in the [HKEY_CURRENT_USER\Console] registry key and its subkeys named for specific executable names / window titles.
Therefore, even if you remove [HKEY_CURRENT_USER\Console] or specific subkeys, starting a program via a shortcut file will still apply the settings stored inside that shortcut file.
To bypass the shortcut-file settings ad hoc, you can start your program directly, using the Run dialog:
Press WinKey+R and enter powershell (for Windows PowerShell) or pwsh (for PowerShell Core), which applies only the registry defaults, if any.
However, to solve that problem persistently, you must modify or recreate the shortcut
file(s) you use to start your program:
To modify the shortcut:
Invoke your program via the shortcut,
then open the system menu (click on the icon in the top-left corner of the window),
select Properties
and modify the properties, notably the colors via the Colors tab.
To recreate the shortcut (instructions based on Windows 10):
In the Start Menu:
Right-click on the application of interest, then select More > Open file location.
In the taskbar:
Right-click on the application of interest, then right-click the application name and select Properties.
Activate the General tab
Copy the value of the Location: field - the folder in which the *.lnk file is located - to the clipboard.
Open File Explorer and paste the location into its address bar, which should open the folder in which the *.lnk file of interest is located.
Once you've located the *.lnk file of interest:
Make a note of:
its exact filename (typically: Windows PowerShell)
its target command line, by right-clicking the file, selecting Properties, selecting the Shortcut tab and copying the value of the Target: field.
its startup directory, as noted in the Start in: field.
Delete the *.lnk file.
Recreate it with the previously noted target command line:
Right-click in an empty part of the File Explorer window and select New > Shortcut
Paste the command line and click Next.
Specify the previous filename, and click on Finish.
Right-click on the new file, select Properties, and paste the startup directory into field Start in:, then click OK.
Drag the new *.lnk file into the Start Menu and/or taskbar, as needed.

Can VSCode always open a default folder (for Ctrl + P searching) even if opening a file in different folder?

Is it possible to have VSCode always have a particular folder ("Directory A") open, so the files inside can be searched using Ctrl + P?
It seems the standard behaviour is that my current "added folder" (i.e. "Directory A") get removed whenever I open a file from a different location ("Directory B").
Closing VSCode and re-opening it always returns me to the last used file (i.e. opening "Directory B" and NOT "Directory A").
How can I force VSCode to always have a certain folder open please?
NB, I've looked into "workspaces" but this doesn't help as whenever opening a file not in the workspace, it seems to close the workspace.
Add Directory A to your workspace using File > Add Folder to Workspace...
Then rather than opening Directory B when you launch VSCode, open the .vscode-workspace file for the workspace that contains both directories.
If there are multiple files in your workspace which match the filename you're searching for using CTRL+P, all the matching files will show up.
The solution, at least on linux, is to create a script with the following content (let's call the script code-standard-path ):
#!/bin/bash
code /path/to/standardDir-or-standardworkspace "$1"
Then from caja right click on a file : open with -> other application.
Then select the command code-standard-path and check Remember this application for "..." files.
Now everytime you double-click on the specific file from whatever location, vscode will open in that predefined directory or workspace.
You can move a bit further and pass the standard path as first argument to the script (e.g. use code "$1" "$2"). So on the open with menu you provide each time the script like this: code-standard-path /path/to/standardDir-or-standardworkspace.
This gives you the ability to open a differrent standard path depending on the file you open (e.g. for .c, .java, .html)
Had the same issue. But there is an easy fix:
On the menu bar go to file File > Preferences > Settings > Window and under Restore Windows select the option preserve.
This will ALWAYS reopen the last session, no matter if you start VS from shell, desktop shortcut or by opening a file.
Open settings File > Preferences > Settings Or by clicking (ctrl + comma)
Type "include" in search bar
Find "Search > Quick Open: Include History"
Uncheck the option

VSCode: Open file in project

I'm using Mac OS X with Visual Studio Code 0.10.10.
How do I use the keyboard to open a file, using its partial name, in the currently open project? I can't find a command in the Command Palette that would enable me to do this. There is a command that does this for Working Files (see screenshot), but not for the currently open project.
> prefix is for running commands in VSCode.
To open a file in the current project press Cmd ⌘ + P and type the full / partial name of the wanted file. VSCode uses fuzzy search, so you can even get away with typos in your input.
There is not a proper command for this but if your file has any file extension you can just open the command palette and replace the > with a .
It will have a section of the open files at the top and "file and symbol results" at the bottom containing every file name containing a . (= all files with a file extension)
If you know the name of the file you can simply remove the > in the command palette and type the name and it will show the file and symbols results again for any file containing what you have typed.
To open known file on a current project if you aware the file name is Ctrl+P Windows.
Open file opening pallet with ctrl+p (on Windows) and cmd+p on Mac OSX.
In that pallet you can either type the file name or a file relative path like shown in the below image
The important point for relative path is that, it should not start with a dot . but should start with a fwd slash /
Absolute path can be used as well.
Ctrl+O opens the command palette right to the file search mode. The command in the shortcuts is "workbench.action.files.openLocalFile".