- 1 year ago
Automated script or program for copying and renaming a file
Comment
1 / 1
To automate the process of copying and renaming a file using a script or program, you can use a programming language like Python. Here's an example using Python:
pythonimport shutil
# Source file path
source_file = 'path/to/source/file.txt'
# Destination file path
destination_file = 'path/to/destination/new_file.txt'
# Copy and rename the file
shutil.copy(source_file, destination_file)
In this example, you need to provide the source file path (source_file
) and the destination file path with the new name (destination_file
). The shutil.copy
function is used to copy the file from the source location to the destination location and rename it.
You can customize the file paths and names according to your requirements. Additionally, you can use this code as a starting point and add any additional logic or error handling as needed.