Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Argument to script should be a filename with a list of mame romnames without file ending.
- # It takes a base directory with MAME EXTRAs files and searches in pre defined comma separated
- # directories like flyers,snap for .png files. These .png files must match the list of romnames
- # found in the file from argument. The list of romnames in file must be new line separated without
- # file extension. The script will create the corresponding directories and copy all matching files
- # to there places.
- # Argument 1 is a file with romnames without file ending separated by new line. In example:
- # bosco
- # bjourney
- # lizwiz
- filename="$1"
- # This is the base directory to look for files to copy. It is assumened that this directory have
- # subfolders with those images. Usually it is the mame base folder, where all these EXTRAs subfolders
- # are found.
- basedir="/media/tuncay/K/roms/Pleasuredome/mame/MAME 0.155 EXTRAs"
- # List of directories to use found in base directory. The list should be comma separated.
- includedir="flyers,marquees,snap"
- # Error messages sent to this file. Contains an entry for each not found image with full path.
- logfile="log_all.txt"
- # Remove previous logfile.
- rm "$logfile"
- # Create all folders to copy files from.
- for dir in $(echo $includedir | sed "s/,/ /g")
- do
- mkdir -p "$dir"
- done
- # counter is just temporary number for the print for each romname.
- counter=0
- # Use the file from argument as the input. Each line represents a romname.
- for line in $(cat "$filename")
- do
- # Proceed only if the line is not empty.
- if [ -z "$line" ];
- then
- continue
- else
- # Print the actual romname in line of file and corresponding number.
- counter=$[$counter+1]
- romname="$line"
- echo "$counter - $romname"
- # Look for each directory in the comma separated list to copy files from.
- for dir in $(echo $includedir | sed "s/,/ /g")
- do
- # Build up final file to look at. If file exists, then copy it into
- # the created folder. If not, write a line that the file does not exist.
- file="$basedir/$dir/$romname.png"
- if [ -f "$file" ];
- then
- cp "$file" "$dir/$romname.png"
- else
- echo "File $file does not exist." >> "$logfile"
- fi
- done
- fi # End of Proceed only if the line is not empty.
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement