Hacking Powershell Rom Trimming Script

BrianCumminger

New Member
OP
Newbie
Joined
Jan 23, 2009
Messages
1
Trophies
1
XP
11
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
40
Location
australia
XP
312
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
53
Location
Wales, UK
XP
953
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
1
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
40
Location
australia
XP
312
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
  • BigOnYa @ BigOnYa:
    I got stuck earlier in a underground chamber without a map, couldnt find a way out, felt like I was stuck in Psi's basement of horrors. (Had to swim underwater to dif room to escape)
  • K3Nv2 @ K3Nv2:
    Psis basement was originally very dark but the meth gave enough light
    +1
  • BigOnYa @ BigOnYa:
    I wonder if in Florida, during concerts instead of lighters they just lift up theyre lit meth pipes.
  • K3Nv2 @ K3Nv2:
    Meth vapes are a hot seller
  • Sicklyboy @ Sicklyboy:
    that's methed up
    +1
  • Sicklyboy @ Sicklyboy:
    Well, that's a new one for me. Cleaning some linear rails for my 3d printer I'm building, spraying the hell out of them with brake cleaner to strip the light oil off of it so I can grease them up properly
  • Sicklyboy @ Sicklyboy:
    This old can of brake cleaner ran out of propellant with like 15% of the fluid left in the can, wtf
  • Sicklyboy @ Sicklyboy:
    Now I have to go run out to my truck to get a new can and it's dark and cold and wet and windy :(
  • K3Nv2 @ K3Nv2:
    Don't huff the cleaner in the store wait tell you get to your car
  • K3Nv2 @ K3Nv2:
    They were talking about how a principal and assistant tried framing a kid with a weed cartridge on the radio and I'm just like how did that kid get hated that much
    +2
  • Sicklyboy @ Sicklyboy:
    of course it's texas
    +1
  • Sicklyboy @ Sicklyboy:
    shithole state
  • K3Nv2 @ K3Nv2:
    Florida would also be acceptable
  • darkscyht3s @ darkscyht3s:
    when reading upon the instructions on how to use YANBF it says to drag apfix.pck and widescreen.pck but there is no apfix.pck in the current version download of twilight 7z
  • darkscyht3s @ darkscyht3s:
    im
    on windows btw
  • SylverReZ @ SylverReZ:
    @darkscyht3s, Make a thread in the DS section.
    +1
  • BigOnYa @ BigOnYa:
    Hi @SylverReZ How are you, at this hour?
  • SylverReZ @ SylverReZ:
    Can't even get to sleep.
    +2
  • kijetesantakalu042 @ kijetesantakalu042:
    Hate how microsoft wants me to use the outlook app instead of letting me simply look at my calendar
  • K3Nv2 @ K3Nv2:
    It's looking out for you
  • kijetesantakalu042 @ kijetesantakalu042:
    I could drive for an hour and suffocate bill gates.
  • kijetesantakalu042 @ kijetesantakalu042:
    Don't fight me, bill
    kijetesantakalu042 @ kijetesantakalu042: Don't fight me, bill