Renaming files

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Post Reply
Robert2
Gold Member
Gold Member
Posts: 673
Joined: 2004 Jun 17, 15:39

Renaming files

Post by Robert2 »

I have files with names like these:

truth-out.org-Billions Against Bayer Here We Come.pdf
nytimes.com-An Email Trail Leads to Gov Walker.pdf
krugman.blogs.nytimes.com-A Lie Too Far.pdf
takingnote.blogs.nytimes.com-Donald Trumps Cynical Play for Womens Votes.pdf

Is there a way to mass rename these files so that everything up to and including the dash character is removed?
TIA.
Robert
User avatar
nikos
Site Admin
Site Admin
Posts: 15803
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Renaming files

Post by nikos »

not at present
i'm not even sure this could be done with regular expression mass rename
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Re: Renaming files

Post by FrizzleFry »

matching the site name prefixes should not be a problem for a regex renamer...

^.+\.(com|org)-

here is a quick PowerShell script that should do it...

Code: Select all

gci *.pdf | foreach-object {
	$_.name
	$newname = $_.name -replace '^.+\.(com|org)-'
	$newname
	''
	#rename-item $_.fullname $newname
}
I commented out the actual rename so you can test it first
Robert2
Gold Member
Gold Member
Posts: 673
Joined: 2004 Jun 17, 15:39

Re: Renaming files

Post by Robert2 »

Thanks a lot! This worked beautifully!
Post Reply