Jump to content

Recommended Posts

Posted

Hello,

 

Does anyone have a script I could use that looks at a folder and sub folders and finds files that are .doc and changes to extension to .docx please?

 

I know its a bit of a bodge, but for what we need it does solve an issue :)

 

Thanks

Posted (edited)

use Bulk Rename Utility (bulkrenameutility.co.uk)

 

On Windows Explorer, Open root folder then do a search *.doc (top right)

Select all (ctrl A) from the search results, then drag them to the Bulk Rename Utility and rename the extension

Edited by bicky
  • Thanks 1
Posted
use Bulk Rename Utility (bulkrenameutility.co.uk)

 

On Windows Explorer, Open root folder then do a search *.doc (top right)

Select all (ctrl A) from the search results, then drag them to the Bulk Rename Utility and rename the extension

 

Been using that for years and didn't know you could do that!! thanks.

Posted (edited)

Set-Location E:\Local\Tmp #Parent Folder - where the files live

$FileList = Get-ChildItem -Recurse | ? {$_.Extension -eq ".doc"} #Gets a list of files where the Extension is = to .DOC

 

# foreach-object loop gets the name of the file and then builds a new file name with the replacement extension - in this case .DOCX

$FileList | % {

$FileNameNew = $_.BaseName + ".docx"

Rename-Item -Path $_.PSPath -NewName $FileNameNew

}

 

# End

 

PowerShell? the above will do what you want, you ask for a script so you get a........

 

Right that will work, forgot about sub-folders!

Edited by HPlum78
Posted

If you need to rename .doc files in different folders often, here's a PowerShell function that would help...

 

function Invoke-Doc2Docx {

   Param(
   [parameter(Mandatory=$true)]
   [string]$Path
   )

   Get-ChildItem -Path $Path -Include *.doc -File -Recurse | ForEach-Object {

       Try {
           Write-Output "Renaming $($_.FullName)"
           Rename-Item -Path $_.FullName -NewName ("{0}{1}" -f $($_.BaseName),'.docx') -ErrorAction Stop
       }
       Catch [Exception] {
           Write-Output "$_.Exception.Message"
       }
   }

}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...