Hacking Powershell Rom Trimming Script

BrianCumminger

New Member
OP
Newbie
Joined
Jan 23, 2009
Messages
1
Trophies
0
XP
1
Country
Canada
Hi, this is my first post here. I was looking around for a way to trim NDS roms simply, and I couldn't find anything other than the command-line trim.exe by ratx, which can't trim in place (results in 2 files) and I wanted to save myself some time. I've been learning Windows Powershell lately so I figured it would be a good way to achieve this goal.

Here is a powershell script to invoke trim.exe on all roms in a directory, and if the trim was successful it will delete the old rom and rename the new one to the old name. As it is written it looks for trim.exe in the current directory, but this can be easily changed as I mentioned in the comments. Remember that running powershell scripts is disabled by default, so you will have to enable them in the following way before you can use this command inside powershell:

Set-ExecutionPolicy RemoteSigned

This allows local scripts to be run but restrict unsigned remote scripts. Here is the code:
(it doesn't appear that I can attach files, so save this text in a .ps1 file)

CODE##################################################
# Written by Brian Cumminger #
# Jan 23rd, 2009 #
# Under no license, do whatever you want with it #
##################################################

#trim-and-rename.ps1

#get all roms and loop through them
$files = Get-ChildItem *.nds

#path to trim.exe, to specify a location other than the current directory,
#replace (Get-Location).Path with "c:\nds\apps" to use c:\nds\apps\trim.exe
$curdir = (Get-Location).Path

foreach ($file in $files) {

$fname = $file.FullName
$fstartname = ('"' + $fname + '"')

#run trim.exe and wait for it to finish
$trimproc = [diagnostics.process]::start(($curdir + "\trim.exe"), $fstartname)
$trimproc.WaitForExit()

#generate name that the trimmed file will have
$trimmedfilename = ($file.FullName.Substring(0,($file.FullName.Length-4)) + '.trim.nds')

#if trimming was successful...
$didTrim = Test-Path ($trimmedfilename)
if ($didTrim -eq "True") {

#delete old untrimmed file and rename new trimmed version
$newfile = Get-ChildItem ($trimmedfilename)
$file.Delete()
$newfile.MoveTo($fname)
}
}

Trim.exe: ratx's blog
Powershell: Microsoft's Powershell Site
 

bRKcRE

Well-Known Member
Member
Joined
Nov 1, 2008
Messages
380
Trophies
1
Age
39
Location
australia
XP
302
Country
why would we need to use your script when NDS Tokyo Trim does the job perfectly?? especially as you have a post count of 1..
 

TrolleyDave

Philosolosophising
Former Staff
Joined
Jan 1, 2007
Messages
7,761
Trophies
1
Age
52
Location
Wales, UK
XP
933
Country
blainy said:
why would we need to use your script when NDS Tokyo Trim does the job perfectly?? especially as you have a post count of 1..

And what about for the people that don't want to use TokyoTrim? As great of a trimmer as it is there are still people that prefer to use other trimmers.
 

Evilmaster1985

Well-Known Member
Member
Joined
Nov 23, 2008
Messages
456
Trophies
0
Location
Middle of nowhere
XP
109
Country
United States
I like my NDS Rom Trimmer v0.22a.
Drag and drop
smile.gif

No trouble with wifi or multiplayer what so ever.
Trimmed over 10gb of NDS roms with it that are in use on my NDS now
smile.gif


Greetz, Vistabuser.
 

bRKcRE

Well-Known Member
Member
Joined
Nov 1, 2008
Messages
380
Trophies
1
Age
39
Location
australia
XP
302
Country
TrolleyDave said:
blainy said:
why would we need to use your script when NDS Tokyo Trim does the job perfectly?? especially as you have a post count of 1..

And what about for the people that don't want to use TokyoTrim? As great of a trimmer as it is there are still people that prefer to use other trimmers.


i probably shouldn't have been so specific by mentioning NDSTokyo trim, but you know what i meant....why would we trust some code written by sumone with no history on the forums here at all, when there are other tools that do the job perfectly..
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • SylverReZ @ SylverReZ:
    Had a ton of bugs and often crashed. It even didn't support DOS compatibility with older games. :feelsbadman:
  • SylverReZ @ SylverReZ:
    I only grew up with Windows XP because I was lucky.
  • RedColoredStars @ RedColoredStars:
    I downloaded XP on dialup when it came out. Overnights for like a week. cuz I couldn't tie up the phone line during the day. It was so awesome and worked so great going from ME to XP.
  • K3Nv2 @ K3Nv2:
    Vga pins were a dick
  • K3Nv2 @ K3Nv2:
    I kind of want down a large pizza at 10am then crash out
  • ZeroT21 @ ZeroT21:
    Having pizza all day? done it
  • K3Nv2 @ K3Nv2:
    Nah pizza hut open at 10:30
  • ZeroT21 @ ZeroT21:
    just buy a stack of pizza and keep the rest you don't need yet frozen
  • K3Nv2 @ K3Nv2:
    Or buy frozen pizza
  • ZeroT21 @ ZeroT21:
    I buy the regular kind, not the frozen stuff
  • ZeroT21 @ ZeroT21:
    supermarket pizza is ass
  • K3Nv2 @ K3Nv2:
    x65 would just yell at me
  • ZeroT21 @ ZeroT21:
    sounds ok, he didn't pull a gun out ,so...
  • K3Nv2 @ K3Nv2:
    $12 large any style pizza deal
  • K3Nv2 @ K3Nv2:
    Each bite is a $1 well spent
  • SylverReZ @ SylverReZ:
    @ZeroT21, Agreed. I hate oven pizza, only from pizza place.
    +1
  • K3Nv2 @ K3Nv2:
    Nah I can still go for totinos
  • RedColoredStars @ RedColoredStars:
    i like totinos party pizzas. lol.
  • RedColoredStars @ RedColoredStars:
    the cracker-like crust is great on those
  • RedColoredStars @ RedColoredStars:
    My neighbor and I are going to make this next month....
  • SylverReZ @ SylverReZ:
    Tiger crust is great.
  • K3Nv2 @ K3Nv2:
    I'm beefing with a neighbor currently each time I ask him for help with something he makes bs excuses then ignores my calls text but seems to randomly speak when I'm done with the project after doing things to help him
  • RedColoredStars @ RedColoredStars:
    DiGiorno Crispy Pan Pizza tasted pretty dang close to Pizza hut pan pizza, but Im not sure if theyve been discontinued or not. Havent seen them locally for a couple of months now.
  • RedColoredStars @ RedColoredStars:
    The croissant crust is still available though, but not quite as good imo.
    RedColoredStars @ RedColoredStars: The croissant crust is still available though, but not quite as good imo.