Remove unwanted dot-files from emulationstation rom-list automagically

Various user-contributed guides for software-related things
Post Reply
User avatar
derebbe
Posts: 48
Joined: Wed Sep 28, 2016 12:30 am
Location: Germany
Has thanked: 51 times
Been thanked: 24 times

Remove unwanted dot-files from emulationstation rom-list automagically

Post by derebbe » Sat Dec 03, 2016 1:34 pm

WARNING: This script deletes all files which match the pattern ".DS_Store" and "._[here can be anything]" within your RetroPie roms folder! Do it at your own risk!

------------------------------------------------------

Someone of you may know the problem, that after copying new roms via SMB to your GbPi0, some additional files appear in retropie which do start with a dot/underscore.
For instance MacOSX creates a .DS_Store file in each folder and for each file one additional file with the same filename but a dot at the beginning.

One solution to remove those files could be to adjust your MacOS Settings, but we can also listen for new created files within the roms-folder and automagically remove unwanted ones.

My solution uses inotifywait which hooks into the filesystem events, with an additional filter for all of our unwanted files we are able to remove them.

Howto:

You need to be logged in with the normal "pi" user via ssh (https://github.com/retropie/retropie-setup/wiki/ssh) to your pi or just use a shell directly.

1) Install inotifywait

Code: Select all

sudo apt-get update && sudo apt-get install -y inotify-tools
2) Create shell script and make it executable

Code: Select all

echo -e '#!/bin/bash\n\ninotifywait -q -m -r ~/RetroPie/roms --event CREATE --format %w%f | grep -P \047\/\.(_.*|DS_Store)$\047 --line-buffered | while read FILE\ndo\n    /bin/rm $FILE\ndone' > ~/clean_dot_files.sh && chmod u+x ~/clean_dot_files.sh
3) Add it to crontab

Code: Select all

(crontab -l ; echo "@reboot /home/pi/clean_dot_files.sh &") | crontab -
That's all. If your something creates other unwanted files, let me know I can easily the filter-regex for you.
I hope that no emulator creates any dot-underscore files within the roms folders for save-states or smiliar, those would be gone as well... Let me know :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest