I want to process a file that resides on Windows using WSL. How do I move/copy the file from Windows to the WSL environment?
Linux Distribution installed for WSL: Ubuntu The file is in Desktop.
I want to process a file that resides on Windows using WSL. How do I move/copy the file from Windows to the WSL environment?
Linux Distribution installed for WSL: Ubuntu The file is in Desktop.
There are two methods mentioned in this website.
I prefer method 2, so will be summarising this method only.
Open your linux distribution, in my case, it is Ubuntu 20.04 LTS.
I find my file in the following path:
cd /mnt/c/Users/<username>/Desktop - /mnt/c is the Windows' C Drive mounted to Linux.
Then copy the file into my WSL's home directory:
cp <filename> ~/
Now go to the WSL's home directory and you can find the file there.
cd ~/
I just found out the ultimate way to access WSL files. In Win 11 anyway, you can just open the file manager. Take a look. 
The WSL CLI experience in Windows still respects the terminal you run wsl command.
Copying from a current directory to a home dir in WSL with PowerShell is possible. All you need is to translate between Windows and WSL file structures.
First, find where your current Windows is mounted within WSL.
$path = wsl pwd
This will result with $path being a WSL mount path like /mnt/C/Users...
Now you can use this variable to run wsl -e to point it to the mounted folder and move files to the native folder structure like `/home/me'.
wsl -e cp $pwd/your_script.sh ~
Just remember that the command will respect variables from the PowerShell terminal but will try to execute it within WSL distro context.
If you are using Visual Studio you can do that easily. Visual Studio enables navigating in WSL files. Open your Ubuntu files in Visual Studio to see them on the left side of Explorer in VS. Right click on the folder you wish to paste your files and click on "Reveal in Explorer". The folder is opened in a window and you can paste your files into that window