Reputation: 61
If I use:
!ls '/Users/martyn/Documents/rawData'
it gives me a list of the files in the required directory.
But I want to paramterize this. I tried:
pathData = '/Users/martyn/Documents/rawData'
!ls pathData
But this gives the error:
ls: pathData: No such file or directory
I can see the problem ... but can't see how to fix it. Any help would be greatly appreciated.
Upvotes: 5
Views: 19560
Reputation: 885
You can list the files and folder in any directory using folling command
%ls pathData
for current directory use
%ls
if you want to go one folder back you can use
%ls '../'
For two folders back
%ls '../../'
Upvotes: 2
Reputation: 11
Maybe you can also use:
from glob import glob
#path_list=glob("put your file path here.extension")
path_list=glob("C:/Users/..../PYTHON/module1/data.jpg")
Upvotes: 1
Reputation: 7373
You can also use:
import subprocess
print(subprocess.check_output(['ls', '-lhS']).decode('utf-8'))
Upvotes: 0