Answers for "rename files with spaces in a folder python"

0

rename files with spaces in a folder python

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> path  = os.getcwd()
>>> filenames = os.listdir(path)
>>> for filename in filenames:
...     os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(' ', '-')))
...
>>>
Posted by: Guest on September-28-2021

Code answers related to "rename files with spaces in a folder python"

Python Answers by Framework

Browse Popular Code Answers by Language