batch copy and replace code 1

batch copy and replace code

@echo off
setlocal
rem get the .lnk target directory
for /f "tokens=* usebackq" %%i in (`type "C:\Users\Abdo\Desktop\Gravity.lnk" ^| find "\" ^| findstr/b "[a-z][:][\\]"`) do (
  set _targetdir=%%~dpi
  )
rem copy the files
copy /y Gravity.pdf %_targetdir%
endlocal

Here is what the above code is Doing:
1. It’s creating a batch file that will copy the file to the target directory of the shortcut.
2. It’s creating a shortcut to the batch file.
3. It’s creating a shortcut to the file you want to copy.
4. It’s running the batch file.
5. It’s deleting the batch file.
6. It’s deleting the shortcut to the batch file.
7. It’s deleting the shortcut to the file you want to copy.

Similar Posts