killerbng icon

Find File location - simple console file

killerbng | PRO | 12/07/18 07:49:34 PM UTC | 0 ⭐ | 318 👁️ | Never ⏰ | []
Python |

410 B

|

None

|

0 👍

/

0 👎

import sys
import os, fnmatch
 
def find(pattern, path):
    result = []
    for root, dirs, files in os.walk(path):
        for name in files:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
    return result
 
a = find(sys.argv[1], sys.argv[2])
print(str(a[0])) # Return the 1st result as string (change this if you want an array with multiple files)

Comments