• Welcome to SCdev.org. Please log in.

Welcome to the new SCdev forums!

Copy and rename save file script

Started by Nintendome, June 18, 2005, 01:17:41 PM

Previous topic - Next topic

Nintendome

This is a php script I wrote to automatically create a save file for each of your roms. It saves you the time of creating them manually one-by-one. If you don't have a server and php installed look into xampp.
<?
//change the following vars, make sure $savefile is in $dir (be sure to use forward slashes)
$dir = "c:/nes/";
$savefile = "NesFileName.sav";
$ext = ".nes";

$handle=opendir($dir);
while( false !== ($file = readdir($handle)) ){
if( strstr($file,$ext) ){
$newfile=str_replace($ext,".sav",$file);
if(!is_file($dir.$newfile)){
if( copy($dir.$savefile, $dir.$newfile) )
echo "<font color=red>".$dir.$newfile." created...</font><br>\n";
} else echo "<font color=blue>".$dir.$newfile." exists...</font><br>\n";
}
}
closedir($handle);
echo "<font color=blue>Done.</font><br>\n";
?>

milk

here's a windows batch file i have for the same purpose
although it requires you to copy the NesFileName.sav from the SC card install directory to the directory of your NES roms

@echo off
for /f "delims=." %%a in ('dir /b *.nes') do (
copy "NesFileName.sav" "%%a.sav"
)

Nintendome

That is much more elegant and accessible (assuming it works). Too bad I didn't find it earlier. :?

Mavromatis

I use FlexRenamer by Naru. :) No need to script but nice work these are.

Mavromatis

I use FlexRenamer by Naru. :) No need to script but nice work these are.

isomorph

Batch file worked great.  Thanks!