0

I used Office File Converter (OFC) to convert my old Office documents to the newer format with a an X (docx, xlsx, pptx). OFC did not provide an option to delete converted documents. Now, I need to traverse through my documents folder to find duplicate file names but with a different extension. For example, my Word document with a name of superuser.doc will also have a converted copy called superuser.docx.

Sun
  • 6,192
  • 10
  • 34
  • 54
  • This tool have option choose output directory for docx files. I don't see point in this question. If you want delete old doc. Simple find all *.doc in input directory and delete them. Since this old doc now docx in different(output) directory. If you want delete docx delete output directory... – crazypotato Nov 28 '14 at 04:41
  • He problem is that sometimes the files do not convert, so if I blindly delete a doc, there may not be an equivalent docx file. I understand your point though... In general, that idea will work if all files convert without issue. – Sun Nov 28 '14 at 04:43
  • 1
    [Try search doc in input directory and docx in output directory,sort and save them](http://superuser.com/questions/344155/how-do-i-recursively-list-filenames-only-in-dos-windows). [In docx list need remove last character on every lane](http://stackoverflow.com/questions/21640713/notepad-how-to-remove-last-character-on-every-line)(this need for compare). Then try use [Notepad++ Compare](http://www.davidtan.org/how-to-compare-two-text-files-using-notepad-plus/) or [WinMerge](http://winmerge.org) for find differences between this lists. – crazypotato Nov 28 '14 at 05:32

1 Answers1

1

This is really very easy in PowerShell. I am providing you with a script that searches the current folder and its subfolders for files with .docx, .xlsx and .pptx extensions, then deletes all files with the same name but with .doc, .xls and .ppt extensions.

The responsibility of navigating to the right folder before running this script lies with you.

Get-ChildItem *.docx,*.xlsx,*.pptx -Recurse | ForEach-Object {
  $filePath = $_.FullName
  $filePath = $filePath.TrimEnd("x")
  Remove-Item $filePath
}

I deliberately used multiple lines and full readable names to make the script understandable. (I could make it a one-liner.) But copying and pasting it whole into PowerShell is supported! :)

Seth
  • 9,000
  • 1
  • 19
  • 34
  • `$a` wasn't really clear but otherwise a really nice approach! – Seth Apr 10 '17 at 07:44
  • Damn it, knew I forgot something. That comment was just there in case you were wondering about the edit. – Seth Apr 10 '17 at 07:47
  • 1
    @Seth Nah. It was obviously a good edit. If I use full command names, I might as well give meaningful names to variables too. –  Apr 10 '17 at 07:48