A Python tool designed to randomize filenames within a directory by renaming files with numbered prefixes (e.g., _1filename.txt), with a reversible process tracked via CSV. Ideal for automation tasks requiring file organization.
Includes an executable in Releases for easy usablilty.
Remember to "sort by name" in Windows for effective (and fastest) results.
Be patient with the initial use of the .exe
Following this it will run normally.
- Randomly prefixes filenames with numbers (e.g.,
_1,_2). - Reverses changes using a CSV tracker (
DO_NOT_DELETE_all_file_names.csv). - Removes prefixes and recreates the CSV if missing.
- Updates CSV with new or deleted files dynamically.
- Portable: Includes a standalone
.exefor Windows users.
- Clone the repository:
git clone https://github.com/AutomationsByAuto/FileRandomizer.git
- Navigate to the project directory:
cd FileRandomizer - Install dependencies:
pip install -r requirements.txt
- Run the script:
python FileRandomizer.py
Note: To build the .exe with PyInstaller, run the script once to generate DO_NOT_DELETE_all_file_names.csv, then use:
pyinstaller --onefile --icon=shuffle.ico --add-data "DO_NOT_DELETE_all_file_names.csv;." FileRandomizer.py- Download
FileRandomizer.exefrom the Releases section. - Place it in the directory with files to randomize.
- Double-click to run. The initial run may be slow; subsequent runs are faster.
Run the script or executable in the target directory and choose an action:
-
rs: Randomly sort files by adding numbered prefixes. -
cb: Revert files to their original names. -
rp: Remove prefixes and recreate the CSV (note: files originally starting with a number may lose that number). -
ex: Exit the program. -
The script creates
DO_NOT_DELETE_all_file_names.csvto track filenames. Do not delete this file, as it’s required for reverting changes. Although therpfunction can mostly fix this issue if the file is deleted. -
In Windows, sort the directory by name to view prefixed files in numerical order (e.g.,
_1file.txt,_2file.txt). -
Note: The
.exemay take a few seconds to load initially due to PyInstaller’s unpacking process.
See requirements.txt for dependencies (e.g., pandas).
I found I was unable to organise a directory of images and videos randomly in Windows so I coded this solution.
Built as my first step into automation engineering, this tool demonstrates file manipulation, user interaction, and portability—core skills for automating repetitive tasks.
MIT License - feel free to use, modify, and distribute.
Ray Pitcher - mass.automation.solutions@gmail.com
Aspiring Automation Engineer | Open to feedback and collaboration!