Here are some strategies to generate unique file names for exports:
-
Timestamp-Based Names
Use the current date and time down to milliseconds to ensure uniqueness.
Example:export_20250520_153045_123.csv -
UUID or GUID
Generate a universally unique identifier.
Example:export_4f9c8b7e-2d47-4d2a-a44c-5aef37f9021b.csv -
Incremental Counters
Append an incrementing number if the base name already exists.
Example:export_1.csv,export_2.csv,export_3.csv -
User or Session Info + Timestamp
Combine user ID or session ID with a timestamp for traceability.
Example:user123_export_20250520_153045.csv -
Hash of Content
Use a hash (MD5, SHA1) of the file content or key metadata to create a unique name.
Example:export_d41d8cd98f00b204e9800998ecf8427e.csv -
Random Strings
Append a random alphanumeric string for uniqueness.
Example:export_X7Y9A2.csv -
Combination Approach
Mix several of the above for better uniqueness, e.g.,export_user123_20250520_153045_4f9c8b.csv
If you want, I can generate sample file names in any format you prefer.