Questions tagged [python-os]

The Python os module provides a portable way of using operating system dependent functionality. Use this tag for questions about using the "os" module.

The Python os module provides a portable way of using operating system dependent functionality.

Links

551 questions
-1
votes
1 answer

How to read file Attribute such as "Author" or "Creator" in a directory using Python?

I am trying to fetch the modified date and Author of the files in a folder. import os PATH="my folder/books" my_list= os.listdir(PATH) Let us suppose customer details.xlsx is one of the files in the books folder How can i fetch the Author or…
jatin grover
  • 396
  • 1
  • 2
  • 10
-1
votes
1 answer

Python os.remove fails to remove

I want to remove files as follows: path = "username/hw/01/" file_list = ["main.cc", "makefile"] files = os.listdir(path) del_files = list(set(files) - set(file_list)) for del_file in del_files: try: os.remove(path + del_file) except…
LewisJS4
  • 11
  • 1
  • 3
-1
votes
1 answer

Move files from folder 1 to folder 2 if the folder 2 does not contain the file

I need to write python code to move a file from one folder (Folder 1 )to another (Folder 2) if the folder 2 does not contain the file. I want to know if we should use shutil.copy
Harikrishna
  • 1,100
  • 5
  • 13
  • 30
-1
votes
1 answer

python socket- send() command doesnt work

i need to write a server and a cliet which do 4 things 1.send the time the message was recived 2.get all the files in a folder 3.copy a file from that folder and create a new file(txt) in another folder 4. close the progrem clint: import socket …
-1
votes
2 answers

String Concatenation '\ ' python

I am trying to concatenate '\' with the path and the filename in the folder but when I try to concatenate, I'm getting EOL while scanning string literal: path = r"C:\Users\karth\Desktop\udacity\2000" add = '\' file = os.listdir(path) ['2000Q1.zip', …
Karthik Elangovan
  • 133
  • 1
  • 2
  • 9
-1
votes
1 answer

linux/wine/python-os parameter to ignore errors

I am running wine on Ubuntu 14 to execute a windows application on multiple files from the shell. From the 3000 files, about 4 or 5 fail and raise a pop up error which stops the loop. Then I need to press OK in order for the loop to continue. Is…
jgozal
  • 1,480
  • 6
  • 22
  • 43
-1
votes
1 answer

How to change path with python script using os module

I'm trying to change the directory of my terminal from a Python script. The program execute successfully but the directory in my terminal doesn't change. Here is the program. os path = "/home/najeeb/Desktop/project/scan" r = os.getcwd() print "\n…
Najeeb Choudhary
  • 396
  • 1
  • 3
  • 21
-1
votes
1 answer

How can os.popen take argument externaly to run another script

I am trying to write a python CLI program using module python cmd. When I try to execute another python script in my CLI program my objective is I have some python script in other folder and CLI program in other folder. I am trying to execute…
Najeeb Choudhary
  • 396
  • 1
  • 3
  • 21
-1
votes
1 answer

os.walk syntax error python

I am trying to get all directories from a specified root, this seems to run fine when I run it on windows by giving it a path, however when I move it to the raspberry pi I get a syntax error for root, dirs, files in os.walk("/home/pi/",…
Johnathon64
  • 1,280
  • 1
  • 20
  • 45
-2
votes
1 answer

Python Os Changing Path

I'm trying to change directory when calling a python file in cmd but it's not working ! I tried all types of slashes & back slashes & escaping, sometimes when the code runs, the directory isn't changing and stays the same where i start the py file…
-2
votes
1 answer

How to get the exit code for "os.popen(command)"?

I am using a shell script to run the commands. When running the command using this os.popen(command).readline() I want to get the exit code of that command. Please let me know how we get the exit code in this case.
Shanthi K
  • 5
  • 6
-2
votes
1 answer

$ variable name in Python to get os.getenv

My curl.trill works: $ = os.getenv('$') cookies = { 'AlteonP': f"AKgyK+bV+AqyP5hdVrxVFA{$}", 'JSESSIONID': '919BAF7B84FEF902E41306B1C27345E8.lgd', } But python throws this error: $ = os.getenv('$') File "", line 1 $ =…
-2
votes
1 answer

What does the 0 stand for at the end of the text which os.system() returns?

What does that 0 at the end of the output stand for?
aNoNyMoUs
  • 61
  • 7
-2
votes
1 answer

Exporting python list to an environment variable using OS library

Let's say I have a list someList = ["a", "b", "c"] and I would like to use os.environ["someList"] = someList to store the list as an environment variable. I am currently getting an error, is there a way to do this?
ppap
  • 251
  • 2
  • 15
-2
votes
1 answer

Python Tkinter askopenfile with entry box

I was hoping anyone has any idea how I could use the askopenfile function in conjunction with an entry box(tkinter) so that the file path is displayed and can be edited in the entry box once selected using askopenfile. Any ideas on how to do this…
Kevin M
  • 11
  • 6
1 2 3
36
37