Skip to main content

All Questions

Tagged with
0 votes
2 answers
4k views

Open cmd with Python Os.system and run commands inside the new opened cmd

I need to click in a button to call a python function (i did this), but now : I need a python script to open a new cmd, and in the opened cmd i want to do 2 commands : Cd and run a python file This ...
Soufiane El Himani's user avatar
0 votes
1 answer
2k views

How to use set environment variables as argument for command line scripts through python script

I'm writing a script to convert files from one format to other, say from t1 to t2. The conversion uses a shell script, to call this I need to set few variables and later pass the files(t1) as ...
Chakrakeerthi Reddy's user avatar
0 votes
1 answer
2k views

run setenv linux command in python script [duplicate]

I want to run setenv command through python script, the linux command is as below setenv MODEL path/to/the/model I tried using os.environ(), but I couldn't get the right syntax. note - I'm using ...
Chakrakeerthi Reddy's user avatar
1 vote
2 answers
3k views

Python script unable to find locate downloads folder and open file

I am writing some automation code using python 2.7 and packages glob, webbrowser, and os to download links using google chrome. I have no issues downloading the file, but once downloaded, my script ...
jod51's user avatar
  • 111
4 votes
3 answers
9k views

How to execute another python file and then close the existing one?

I am working on a program that requires to call another python script and truncate the execution of the current file. I tried doing the same using the os.close() function. As follows: def ...
OshoParth's user avatar
  • 1,552
0 votes
1 answer
27 views

identify a file with specific chars present in it and rename the file

I am trying to find and rename below files using below script IYBR2C.YGPSWS.SL.1.M.20190503170641.csv to SAK_BB_AL.csv QWEJ1P.YGPSWS.SL.1.M.20190508122932.csv to SAM_SG_MO.csv SCPR1C.YGPSWS.SL.1.T....
Roy's user avatar
  • 3
0 votes
1 answer
36 views

Renaming files os.rename() to timestamps returns weird string

So I am trying to rename some files to the time in their creation date using os.stat("file").st_stat. Then I pop the superfluous information, I only need the time because they are already sorted by ...
enpap-x's user avatar
  • 15
1 vote
1 answer
415 views

How to rename/replace a particular keyword with unicode character for all files and the associated folders?

I have the following files and subdirectories in a directory ('input_folder') and I would like to change the name of all the files with '.dat' extension and all the folders that have a particular ...
Tom Kurushingal's user avatar
1 vote
1 answer
353 views

Compare previous file size with the current filesize and flag

I have a bash script which loops through all YAML files in the yaml directory, executing a python script. This python scripts simply prints out if the JSON file exists along with its file size as well ...
arousa yasser's user avatar
2 votes
1 answer
516 views

os and subprocess not finding binaries on Windows 10 anymore

Okay so my best guess currently is that I've severely screwed up my python environment somehow and I have no idea how. First off, I have tried uninstalling and reinstalling (actually upgrading from ...
TheKewlStore's user avatar
1 vote
1 answer
1k views

How to ignore hidden files when using os.stat() results in Python?

I'm trying to get the time of last modification (os.stat.st_mtime) of a particular directory. My issue is I have added a few metadata files that are hidden (they start with .). If I use os.stat(...
wcarhart's user avatar
  • 2,813
-1 votes
1 answer
2k views

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 ...
jatin grover's user avatar
-2 votes
1 answer
2k views

Getting error regarding "os" module of python

I am using python2.7 on ubuntu system. I am getting following errors while working with "os": AttributeError: 'module' object has no attribute 'fsencode' On this line: directory=os.fsencode(indir) ...
vigna purohit's user avatar
8 votes
3 answers
18k views

How to get the filesystem's root directory in Python?

Situation: I need to find the top level [root] directory of any operating system using the most Pythonic way possible, without system calls. Problem: While I can check for the operating system using ...
Timothy Wong's user avatar
5 votes
5 answers
16k views

How to access file in parent directory using python?

I am trying to access a text file in the parent directory, Eg : python script is in codeSrc & the text file is in mainFolder. script path: G:\mainFolder\codeSrc\fun.py desired file path: G:\...
Edmund Carvalho's user avatar

15 30 50 per page