osx - Python filename change -
I have a lot of videos in my directory on my Mac, which have a specific string in the file name that I want Remove but I would like to keep the rest of the file name as it is. I'm running this dragon script from the terminal.
I have this syntax but it does not seem to work, is it practical to use it? It seems that this is the best way to do this work, which is why I do not think it works.
from OS import name, listdir text = "Remove some file name for files in x files" list = listdir ("/ users / admin / desktop / Dir_of_videos /") in some text I want : If the files in the text: os.rename (files, files. Location (text, ""))
The problem is that when you are using listdir you get incomplete paths, basically, it only gives files in the directory without a prepaid path to the directory This should work :
import os in_dir = './test' extract = 'hello' path = [os.path.join (in_dir, file) file in oslistdir (in_dir) if file in path Extract in file for]: os.rename (file, file. Location (""))
Comments
Post a Comment