Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - RchGrav

Pages: [1]
1
I wanted to have a way to automatically divide a folder with too many files in it for the Everdrive N8 into subfolders that never exceed the maximum allowed.. So, I wrote a windows batch file that automatically splits a folder of .nes files into 256 per folder.  The script will only act upon files with the .nes extension in path you target.. If it finds .nes files in that path it will break them down into subfolders.

3 ways to run this script.  (Save it as a .bat or .cmd file..  I'm using process.cmd as the file name)

#1. Just put it in the folder you wish to process and double click it.
#2. Put this command in your path and change to the directory you want to process and type the command.
#3. Type the command and use the path you wish to process as a parameter.*   Like This--> process F:\ROMs\USA\
(*Remember to put quotes around the path if it has spaces.)

Hope its useful.
Give it a try and let me know what you think. 

RchGrav

Code: [Select]
@echo off
setlocal enabledelayedexpansion enableextensions
pushd "%1"
if exist "%~dp1*.nes" (
    echo Processing NES files.
) else (
    echo NES files not found at this path.
    EXIT /B 99
)
for %%* in (.) do set Folder=%%~nx*
set fnum=0
:top
set /a fnum+=1
set cnt=0
mkdir "!Folder! !fnum!"
echo|set /p=.
for /f "delims=:" %%A in ('DIR /ON /B *.nes') do (
    setlocal disabledelayedexpansion
    call :movenes "%%A"
    endlocal
    set /a cnt+=1
    if !cnt! == 256 goto top
)
goto done
:movenes
set "file=%~1"
setlocal enabledelayedexpansion
move "!file!" "!Folder! !fnum!" >nul
endlocal
goto:eof
:done
echo Done!
popd

Pages: [1]