[GLLUG] CLI help

Nathan Hartley nathan at 7hartleys.org
Fri Mar 30 16:36:42 EDT 2012


If that XP system has Powershell installed*, the following one-liner
would remove spaces and exclamation marks from any .jpg file,
recursively, starting in the current working directory.

Get-ChildItem * -include *.jpg -recurse | ForEach { Rename-Item $_
($_.Name -replace '!|\s','') -Verbose }

And the same query, with a bit more of a bash look to it...

ls * -i *.jpg -r | %{mv $_ ($_.Name -replace '!|\s','') -v}

If you want to try removing only the spaces, remove the !| in the
replacement operation.


* Available for XP and Server 2003 as an optional install at
http://update.microsoft.com/ and built-in to Vista and Server 2008
forward.


On Fri, Mar 30, 2012 at 2:05 PM, J Neveau <neveauj at gmail.com> wrote:
> I would like to rename all of the files, leaving their sequential numbers
> intact, but remove all of the exclamation points and the single space
> after the exclamation points.


More information about the linux-user mailing list