Hard symbolic link: Specifiy "Start in:" and Parameters - windows-10

I'm using
mklink /h "C:\Shortcut.exe" "C:\Real.exe"
to create a hard symbolic file link.
However, I don't see how I could specify the "Start in:" property for the Target file or parameters.
Is there a way to do that?

You can create Shortcut.bat (instead of a link) and write below command into it:
call "absolute\path\of\your\excecutable" %*
Example:
#call "C:\Program Files (x86)\GnuWin32\bin\openssl.exe" %*
Save above lines in openssl.bat everywhere you need a shortcut.

Related

Problem with temporary folder location in NodeJs Azure Function

In my function I'm writing something to a file.
The file path provided by me is d:/local/temp, as suggested in documentation.
The command successed and next in the same function I'm listing the directory content, the file is there.
But when I go via console or Kudu to d:/local/temp, it doesn't contain the content I created. I can confirm it with 'dir filename /s on D drive'
When I run the function again I still can list all previously generated files, so they didn't go
So the d:/local/temp in Kudu/console for the App function and the nodejs code is not the same path, but how I can find the real location of my files?
Please try to add an additional option /B or /b for the command dir <filename> /S to show the full path of a file, as below.
dir <filename> /S /B
# the result is like D:\<full-parent-path>\filename
Fig 1. Sample to find files named host.json and show the full path

Possible to make a backup of original file in vim?

Is it is possible to make a copy of original file before writing the new buffer to the file without having to leave vim and copy it manually?
How about this? After editing the file, before :wq, you can do:
:!cat myfile.txt > backup.txt
and then save using :wq. The previous content would be stored in backup.txt
UPDATE
I realized that my solution might be a little complicated for beginners and unnecessary for single files backups, so if you want a simple solution just use:
:!cp % ~/
The % register keeps the name of the file and with this extern command you can copy the current file to your home folder or you can change it to any folder you want.
In Windows you can use this to send to a backup folder on C::
:!copy % \backups\
You can turn in a shortcut on your .vimrc with something like:
nnoremap .b :!cp % ~/
Old Answer:
I had the same need to backup before save the modifications, so I created a Bash and a Batch(for Windows) file that backups all the files that I want and used this conditional statement on .vimrc to choose automatically between the two systems:
if has("win32")
nnoremap <leader>bc :! C:\C\SCRIPTS\backupWIN.bat<cr>
else
nnoremap <leader>bc :!bash /home/vini/C/SCRIPTS/backup.sh<cr>
endif
Here the code for the Bash version:
#!/bin/bash
#adds the date to folder(you can change the date format)
now=$(date +"%d_%m_%Y_%H;%M;%S")
mkdir /home/vini/backups/C_BKP/pre_alpha/$now
cp -r /home/vini/C /home/vini/backups/C_BKP/pre_alpha/$now
echo "saved in: /home/vini/backups/C_BKP/pre_alpha/"$now
Here the code for the Batch file:
set start=%time%
::I didn't managed to make it print the seconds, so I choose to
::override the same files if I save twice in the same minute
#echo off
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mydate=%%a-%%b-%%c)
For /f "tokens=1-4 delims=/:" %%a in ('time /t') do (set mytime=%%ah%%bm%%c)
mkdir C:\Users\vini\Desktop\C\C-%mydate%-%mytime%
::careful with xcopy , read the documentation before modify it
xcopy /E /Y C:\C C:\Users\vini\Desktop\C\C-%mydate%-%mytime%\
You just need to change the name of the directories for match your folders and you are good to go.
As #Sato Katsura pointed out, it is patchmode:
:set patchmode=.orig
I just simply use:
:!cp % %.backup
Which will create a new file in the same location with .backup appended to it.

Search for a file and open the path in CMD

I would like to achieve the following in CMD:
Will search for a specific filename - This I know how to do, with dir /s filename
Once found it will bring me to that path.
Example: I am now on C:\, if that file was found in C:\test then it will open C:\test in command prompt.
Alternatively, I would like just to copy the found file to a path I will specify. I just don't know how to do it, since I don't know the path where the file will be stored (it's different every time).
Thanks in advance!
I'm a liitle confused with your question but I will try to walk you through a batch code I wrote to help you with this.
dir /b /s "test.txt" > "%userprofile%/Desktop/result.txt"
::find the file path to the file you want to find and insert it in a .txt file
::you made called result.txt (also %userprofile% is a variable that brings you to
::your user directory ex C:/users/admin)
for /F "tokens=*" %%A in (%userprofile%/desktop/result.txt) do (
set var1=%%A
)
::set the variable var1 equal to the first (well... only) line in the file.
::I could explain what that for loop means in detail but just remember that %%A
::is a variable set from what was found when looping through the result.txt.
xcopy /s "%var1%" "C:/wherever/you/want/it/to/go"
did this help??

Move 300 images from a folder (contains 800 images) to another based on file name list

I need to move 300 images from a folder (contains 800 images) to another folder. The file name list of these 300 images are available in the excel format. Is it possible to move them via programming instead of search the file and move it one by one? Our IT told me he can't separate these files. Do you have any solution? Many thanks in advance!!!
Here's one way of doing this - I am assuming you are on Windows. First, save text file called ListOfImages.txt that contains the names of the images you wish to move - put one image on each line and include the extension. Then, save the following into a file called movefiles.cmd:
#echo off
set Source=C:\Users\YourName\Desktop\moving\MovingFrom
set Target=C:\Users\YourName\Desktop\moving\MovingTo
set FileList=C:\Users\YourName\Desktop\moving\ListOfImages.txt
echo.
if not exist "%Source%" echo Source folder "%Source%" not found & goto Exit
if not exist "%FileList%" echo File list "%FileList%" not found & goto Exit
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('type "%FileList%"') do move "%Source%\%%a" "%Target%"
:Exit
echo.
echo press the Space Bar to close this window.
pause > nul
You will want to change the variables for Source, Target, and FileList to match where you have those folders and the ListOfImages.txt on your machine. After you have saved this file (make sure it has the .cmd extension, you should be able to double-click it and it will run the commands in your Command Prompt.
For example, say my MovingFrom folder contains the following:
And I only want to move Image1.png and Image2.png -- then my ListOfImages.txt file would like this:
After running moveFiles.cmd (provided I have changed the necessary variables to point to the right folders/places on my machine), my MovingTo folder should contain the following:
Notice that Image2.png was not moved because it was not listed in the ListOfImages.txt text file.

I would like a script to search within text files a certain pattern of strings and move those files to another directory

I need to know how to perform an advanced search on a text file using tools like notepad++, freecommander and windows if possible. A bat script file will be great.
The problem is that i need to search through about 1000 txt files in a directory. I need to know form those 1000 txt files which have a string in the form of for example "SYR_SHA/245/4". I just want it search for the pattern for example *****_******/*****/****** where * are characters that can change in number.
There must be an _ between the first and second set of characters as seen above in the example.
the script should go through the entire txt file and search for the above pattern. The script should then Move all the results in to a seperate directory
Many Thanks
Create this batch file and copy it into your folder where you have all the 1000 .txt files
Change the yourdestinationdirectory directory and run the batch file
#Echo Off
FindStr /M /R "[a-zA-Z]*_[a-zA-Z]*\/[0-9]*\/[0-9]*" *.Txt > findstr.out
For /F "tokens=*" %%a In (FindStr.out) Do call :move_Rtns %%a
del FindStr.out
Exit /B
:move_rtns
copy %1 yourdestinationdirectory\*
del /Q %1
Exit /B
Please change the Regex according to your requirement, for eg. If you are expecting number and letter together you can replace [a-zA-z] with [a-zA-Z0-9]
Good luck

Resources