0

I want to copy a directory requests from current directory to *c:\Python27\Lib* (Python installed directory) using batch file.

Reason for using batch file is that user can double click this file and directory will get copied to destination.

But if different python version is installed then installed path will be different.

I found a link on stackoverflow How can I know python's path under windows? for this but i can't write this in batch file because its a python code.

So what should i write in batch file so that i can copy the requests folder from current directory to the python path under windows ?

Community
  • 1
  • 1
Patrick
  • 2,464
  • 3
  • 30
  • 47
  • `where python.exe` will tell you which python interpreter they launch by default(assuming it is on their path) if thats what you want to know, not sure that will guarantee where they would want it installed ... why not make a python install script instead? (eg setup.py) assuming its a library of some sort ... if its a program why not make an installer with pyinstaller? – Joran Beasley Jun 17 '14 at 05:20
  • @JoranBeasley Actually i want to start an application op python using that batch file, that's why i want to know the path of python.exe and that application has dependency of requests library so i want that file to copy requests library(present in current dir) and then start application and i want to do both using single file with double click – Patrick Jun 17 '14 at 05:24
  • sounds like you should just use pyinstaller ... – Joran Beasley Jun 17 '14 at 05:26
  • @JoranBeasley i dont know about pyinstaller, but i will read about it and hope this will work for me – Patrick Jun 17 '14 at 05:28
  • 1
    it makes your script a runnable exe and automatically includes your python version and libraries so you just double click to run `c:\Pyinstaller\pyinstaller.py --onefile my_script.py` – Joran Beasley Jun 17 '14 at 05:29
  • 1
    assuming python is in the path this will give you location (as run from cmd line, change `%` to `%%` in batch `for %P in (python.exe) do @echo %~$PATH:P` – wmz Jun 17 '14 at 07:07
  • It depends on your configuration. I dk why you tag batch for a python question. But you can search the path for it. Rem Is filter.bat's folder in the path `if not "%~dp0" == "%~dp$PATH:0"` searches the path for a batch file. See `call/?` and `for /?` for what the above means (at the end of each commands help). – phd443322 Jun 17 '14 at 09:43
  • @wmz on command line your command is working, how can i combine your command to start application in a directory? means i want to execute this line `@c:\python27\python.exe work` work is directory containing application files. Can u give me command for this ? – Patrick Jun 23 '14 at 08:00
  • @wmz i combined command like this `for %%P in (python.exe) do SET PYTHON_PATH=%%~$PATH:P @%PYTHON_PATH% dcpp` and this is working fine. I stil didn't understood your command, please explain it – Patrick Jun 23 '14 at 09:13

1 Answers1

0

Code for batch file:

for  %%P in (python.exe) do SET PYTHON_PATH=%%~$PATH:P
@%PYTHON_PATH% dcpp
Patrick
  • 2,464
  • 3
  • 30
  • 47