Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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(' ', '-')))
...
>>>
Comment

PREVIOUS NEXT
Code Example
Python :: Publish Image msg ros python 
Python :: migrations.rename_field django 
Python :: python sys.argv exception 
Python :: video capture opencv and multiprocessing 
Python :: django media url 
Python :: python dropbox 
Python :: matplotlib larger chart 
Python :: Create chatbot in Python - Source: NAYCode.com 
Python :: plot neural network keras 
Python :: random.uniform python 
Python :: Creating and writing to a new file 
Python :: wav file to array python 
Python :: legend for pie chart matplotlib 
Python :: python format strings 
Python :: pyton count number of character in a word 
Python :: gpt-3 tokenizer python3 
Python :: length of int in python 
Python :: python if condition 
Python :: pandas dataframe to excel hyperlink length limit 
Python :: cuda memory in pytorch 
Python :: Python NumPy ndarray flatten Function Example 
Python :: how to plot kmeans centroids 
Python :: rename column by indexing 
Python :: numpy set nan to 0 
Python :: executing curl commands in python 
Python :: axios django csrf 
Python :: python check if file is writable 
Python :: how to make software in python 
Python :: change month name in python 
Python :: python list deep copy 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =