Build Your Own Arcade Controls Forum
Main => Main Forum => Topic started by: rodneykristy on May 17, 2016, 08:29:15 am
-
Ok, so I'm trying to figure out how to write a .bat file to copy only select rom files from a text list to another directory. I haven't wrote a .bat file in years and not sure how to go about this. The rom list is basically my favorite games I have saved in MAMEUIFX which is stored in the favorites.ini file. I really want to just copy that list and insert it into a .bat file so I can run it to copy only my favorite rom files to another drive to cut down on gigabytes of space. I only have about 200 or so games on that list but it's still time consuming to manually copy the roms to another drive. It would be awesome to be able to update my favorites and then recopy them ever so often with any new ones I've added to that list whenever I update my roms. Basically the list looks something like this...
1941u
1942
1943u
1944
19xx
aliensu
altbeast
armwaru
astdelux
asteroid
astorm
atetris
avengrgs
avspu
baddudes
batcir
batman
berserk
I would just paste that into a .bat file and run it to copy only those roms. Hope that makes sense and thanks in advance for info you have regarding this.
-
for /f "delims=" %%i in ([list].txt) do copy "[source]\%%i.zip" "[destination]"
-
Can you explain this a little in detail? I'm not sure what all this means. I'm not very good at writing .bat files at all. Thanks
-
This is the contents of your file. Copy this text into notepad and save it as copyroms.bat
@echo off
SET SRCDIR=C:\PATH\TO\SOURCE
SET DSTDIR=C:\PATH\TO\DESTINATION
SET MYLIST=C:\PATH\TO\MYLIST\mylist.txt
FOR /F "tokens=*" %%A in (%MYLIST%) do copy %SRCDIR%\%%A.zip %DSTDIR%
Edit the file to suit your needs. SRCDIR is where your ROMS are located. DSTDIR is the path to where you need the ROMS to be copied. MYLIST is a textfile with the following contents:
1941u
1942
1943u
1944
19xx
aliensu
altbeast
armwaru
astdelux
asteroid
astorm
atetris
avengrgs
avspu
baddudes
batcir
batman
berserk
-
And here's the bat-file if your foldernames contains spaces:
@echo off
SET "SRCDIR=C:\PATH\TO THE\SOURCE"
SET "DSTDIR=C:\PATH\TO THE\DESTINATION"
SET "MYLIST=C:\PATH\TO THE\MYLIST\mylist.txt"
FOR /F "USEBACKQtokens=*" %%A in ("%MYLIST%") do copy "%SRCDIR%\%%A.zip" "%DSTDIR%"
IMPORTANT! Only edit the lines that starts with SET
-
You can use an editor that has a macro feature for that. I recommend notepad++, which is free (https://notepad-plus-plus.org/).
Go to your roms folder. Make a new folder named 'favs' (without the ').
Open up notepad++. Open the .txt file that contains the rom names.
Go to the top of your file. Click at the first position to make sure that the cursor is positioned before the first letter of the first romname.
Go to the 'macro' menu, select 'start recording'.
Type 'copy ' (without the '), hit the 'end' key to go to the end of the line.
Type '.zip favs\' (without the '), then hit the 'home' key to go to the beginning of the line. You should now have something like 'copy firstromname.zip favs\'
Hit 'arrow down' to go to the beginning of the next line.
Go to the 'macro' menu, select 'stop recording'.
In the 'macro' menu, select 'run a macro multiple times', then 'run until the end of file'.
Use 'save as' to save the file as 'roms.bat' to your roms folder.
Start roms.bat, it will copy the roms into the favs folder.
-
Sorry for late reply
for /f "delims=" %%i in ([source]\%%i.zip" "[destination]"
[source] is just directory where You have roms ie. F:\roms, [destination] is place where You will be store copied files ie. P:\roms and is your file where You have rom list (without extension). Loop for will basically copy files according to content in .txt.
Just put this simple function in txt file and named it for example copy_roms.cmd
[/list]