I ended up writing my own simple function for this. Primitive, but gets the job done:
def uniquify(path):
filename, extension = os.path.splitext(path)
counter = 1
while os.path.exists(path):
path = filename + " (" + str(counter) + ")" + extension
counter += 1
return path
Related Contents:
- How do I delete a file or folder in Python?
- Find all files in a directory with extension .txt in Python
- Writing a list to a file with Python, with newlines
- open() in Python does not create a file if it doesn’t exist
- How to identify on which OS Python is running on?
- Print string to text file
- Read .mat files in Python
- Automatically creating directories with file output [duplicate]
- Reading binary file and looping over each byte [duplicate]
- Does reading an entire file leave the file handle open?
- Lazy Method for Reading Big File in Python?
- How to open a file using the open with statement
- Writing a Python list of lists to a csv file
- How to get the PATH environment-variable separator in Python?
- Python Pandas: How to read only first n rows of CSV files in?
- Deleting all files in a directory with Python
- Open files in ‘rt’ and ‘wt’ modes
- How to write a multidimensional array to a text file?
- python: get directory two levels up
- When to use os.name, sys.platform, or platform.system?
- Python, Pandas : write content of DataFrame into text File
- Determining Whether a Directory is Writeable
- What is a good way to handle exceptions when trying to read a file in python?
- How to identify which OS Python is running on?
- How can I delete a file or folder in Python?
- How can I safely create a directory (possibly including intermediate directories)?
- Does Python have an argc argument?
- List Directories and get the name of the Directory
- What is the return value of os.system() in Python?
- Saving response from Requests to file
- Size of an open file object
- open file in “w” mode: IOError: [Errno 2] No such file or directory [duplicate]
- Running windows shell commands with python
- Read from a log file as it’s being written using python
- Error when creating a new text file with python?
- How to change the user and group permissions for a directory, by name?
- python mkdir to make folder with subfolder? [duplicate]
- How to write to .txt files in Python 3
- What is the difference between rb and r+b modes in file objects [duplicate]
- Do I need to pass the full path of a file in another directory to open()?
- Write file with specific permissions in Python
- A system independent way using python to get the root directory/drive on which python is installed
- How to write to a file without overwriting current contents? [duplicate]
- python try:except:finally
- Python File Slurp
- How do I create an incrementing filename in Python?
- What’s the difference between io.open() and os.open() on Python?
- Is it possible to create an operating system using Python? [closed]
- python write string directly to tarfile
- File mode for creating+reading+appending+binary