Author Topic: [HELP] Create Favorites List batch file  (Read 1672 times)

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
[HELP] Create Favorites List batch file
« on: January 16, 2021, 09:18:30 PM »
At times I tried to use this script but I was unsuccessful, I configured the path it asks for and put it in the romlist folder, but when I try to create a list from that .bat it reads Arcade.tag it writes inside a Favorites.txt file but when he goes to read the next EX platform: Sega Genesis.tag or Super Nintendo.tag he returns me a message:

Error:
Code: [Select]
   AM favorites romlist generator script for Windows
==========================================================
- Backing up old Favorites.txt file
- Gathering list of favorites (tag files)
- Processing tag file: Arcade.tag
- Searching rom list: Arcade.txt for rom: 64street
- Favorites.txt romlist generated. 1 romlists read, 1 favorites written to disk
- Done

Add a display in Attract Mode and set its romlist to the newly created Favorites.txt
- Processing tag file: Sega Genesis.tag
- Searching rom list: Sega Genesis.txt for rom: Duke Nukem 3D (Brazil)
FINDSTR: could not open Nukem
FINDSTR: could not open 3D
FINDSTR: could not open (Brazil)
FINDSTR: could not open Nukem
FINDSTR: could not open 3D

.bat:
Code: [Select]
@echo off
setlocal EnableDelayedExpansion EnableExtensions
rem ================================================================================
rem This script basically does the same thing as DM's favorites romlist generator
rem but on Windows [Shouts to him for the pi version ;)].
rem How it works:
rem It grabs all the (tagged) favorites from every tag file, searches for them
rem through all the romlists, then generates a romlist called Favorites.txt
rem Written by Steve Sherrod, 05/20/17, as part of project HyperPie Expanded
rem ================================================================================

rem Default path (on windows). This should point to your attract modes romlists dir
cd "D:\AM\romlists\"

echo ==========================================================
echo     AM favorites romlist generator script for Windows
echo ==========================================================

sleep 1

echo - Backing up old Favorites.txt file

rem remove the old Favorites.txt and create the backup
if exist Favorites.txt (
move /y Favorites.txt Favorites.txt.backup
)

echo - Gathering list of favorites (tag files)

set /a numfavorites=0
set /a romlist=0

rem loop through each tag file
for %%f in (*.tag) do (
echo - Processing tag file: %%~nf.tag
set /a numtagfiles=numtagfiles+1

rem loop through favorites stored in tag file
for /f "tokens=*" %%a in ('type "%%~nf.tag"') do (

set /a numfavorites=numfavorites+1
set favorite=%%a

echo - Searching rom list: %%~nf.txt for rom: %%a

rem loop through each rom file and parse favorited (tagged) roms
for /f "tokens=*" %%s in ('type "%%~nf.txt"') do (
set /a romlist=romlist+1
set str=%%s
rem Search current line (for current favorite substring) and if found, append it to Favorites.txt
echo."!str!" | findstr /C:%%a>nul && (
echo "!str!">>"Favorites.txt"
)
)
)

echo - Favorites.txt romlist generated. !numtagfiles! romlists read, !numfavorites! favorites written to disk
echo - Done
echo.
echo Add a display in Attract Mode and set its romlist to the newly created Favorites.txt
)


PS: At the end of the process it only generates the list of arcade favorites, the others are not generated.

Could you help me, please?

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
Re: [HELP] Create Favorites List batch file
« Reply #1 on: January 17, 2021, 10:25:59 AM »
Resolved or code was incomplete, after several tests I was able to solve the problem now and create a list of favorite games from any platform.

PS: If you use it on the C:\ disk you should keep it like this: cd "C:\AM-2.6.1\romlists\"

PS1: If you use it on the D:\, E:\ or Other disk you should keep it like this: cd /d "D:\AM-2.6.1\romlists\"

Correct Script Below copy and save as .bat or .cmd and put it in your attractmode folder:

Code: [Select]
@echo off
setlocal EnableDelayedExpansion EnableExtensions
rem ================================================================================
rem This script basically does the same thing as DM's favorites romlist generator
rem but on Windows [Shouts to him for the pi version ;)].
rem How it works:
rem It grabs all the (tagged) favorites from every tag file, searches for them
rem through all the romlists, then generates a romlist called Favorites.txt
rem Written by Steve Sherrod, 05/20/17, as part of project HyperPie Expanded
rem     Modified, Implemented and Optimized by 17/01/2021 arthurvalenca.
rem ================================================================================

rem Default path (on windows). This should point to your attract modes romlists dir

cd /d "D:\AM-2.6.1\romlists\"

echo ==========================================================
echo     AM favorites romlist generator script for Windows
echo ==========================================================

rem remove the old Favorites.txt and create the backup

echo - Backup old Favorites.txt file
if not exist "Favorites_Backup\" mkdir Favorites_Backup
if exist Favorites.txt (
copy Favorites.txt Favorites_Backup\Favorites_bak.txt
del Favorites.txt
    )

echo - Gathering list of favorites (tag files)

set /a numfavorites=0
set /a romlist=0

(echo #Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons;Series;Language;Region;Rating) > Favorites.txt


rem loop through each tag file

for %%f in (*.tag) do (
echo - Processing tag file: %%~nf.tag
set /a numtagfiles=numtagfiles+1

rem loop through favorites stored in tag file

for /f "tokens=*" %%a in ('type "%%~nf.tag"') do (
set /a numfavorites=numfavorites+1
set favorite=%%a
echo - Searching rom list: %%~nf.txt for rom: %%a

rem loop through each rom file and parse favorited (tagged) roms

for /f "tokens=*" %%s in ('type "%%~nf.txt"') do (
set /a romlist=romlist+1
set str=%%s

rem Search current line (for current favorite substring) and if found, append it to Favorites.txt

echo."!str!" | findstr /C:"%%a">nul && (
echo !str!>>"Favorites.txt"
)
)
)

echo - Favorites.txt romlist generated. !numtagfiles! romlists read, !numfavorites! favorites written to disk
echo - Done
echo.
echo Add a display in Attract Mode and set its romlist to the newly created Favorites.txt
)