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.
-
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...– crazypotatoNov 28, 2014 at 4: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.– SunNov 28, 2014 at 4:43
-
1Try search doc in input directory and docx in output directory,sort and save them. In docx list need remove last character on every lane(this need for compare). Then try use Notepad++ Compare or WinMerge for find differences between this lists.– crazypotatoNov 28, 2014 at 5:32
1 Answer
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! :)
-
-
Damn it, knew I forgot something. That comment was just there in case you were wondering about the edit.– SethApr 10, 2017 at 7: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.– user477799Apr 10, 2017 at 7:48