Bulk File Renamer
Create a set of files, then rename all of them by adding a sequential number prefix (e.g. 1_photo.jpg, 2_photo.jpg), matching the notes' own renaming pattern.
Approach: the script creates its own files first (since a fresh judge run has no pre-existing folder to work with), then loops over them in a fixed, sorted order, using os.path.splitext() to preserve each file's extension while renaming.
Input: One line: how many files to create and rename, n.
Output: One line: the resulting file names in the folder, sorted, printed as a Python list.
3
['1_photo.jpg', '2_photo.jpg', '3_photo.jpg']
- 1 <= n <= 50
Hint 1
sorted(os.listdir(folder)) gives a predictable, repeatable file order to rename in.
Hint 2
os.path.splitext(filename)[1] gives the extension (like ".jpg"), which should be preserved in the new name.
Hint 3
os.rename(old_path, new_path) performs the actual rename, one file at a time.
Since a fresh script run has no files to rename yet, it first creates n sample files itself. Looping over sorted(os.listdir(folder)) (sorted for a predictable order) and using os.path.splitext() to keep each file's extension, os.rename() gives every file a sequential "<n>_photo<ext>" name — mirroring the notes' own renaming loop exactly.