python 2.7 - Get directory path made by 'os.makedirs' as variable -


python2.7

filenamepath variable created file path of quicktime mov. here checking if folder filename of quicktime mov (but .folder @ end of foldername) exists , if not, os.makedirs creating one.

how assign directory path variable? want use shutil.move move .mov .folder.

import os  if not os.path.exists(filenamepath.replace(".mov", ".folder")):     os.makedirs(filenamepath.replace(".mov", ".folder")) 

your best best assign variables target folder names:

filenamepath = "/some/path/to/my_video.mov" target_dir = filenamepath.replace(".mov", ".folder")  if not os.path.exists(target_dir):     os.makedirs(target_dir)  shutil.move(filenamepath, target_dir) 

that clarify intention of code significantly.


Comments