remove .doc if .docx exists with same name?

March 21, 2011 at 13:21:25
Specs: Windows XP
I am going through the process of converting some 29,000 .doc and .xls and .ppt and many other office files into the 2007 extension here at work but I am doing it locally first so I don't run into any unexpected problems. Here is a problem I am having. Some of the .doc conversions might not work because when processing the files the Word Convertor program that microsoft provided ran into an unexpected error for what ever reason. For these files that did not get converted I want to keep them and maybe convert them later.

So I need to write a line of code that will delete the filename1.doc if filename1.docx exists.

Really all I am trying to do is save space. This will free up about 500mb-1gb since the majority of the space on the drive is older office 97-2003 files.

Thanks,
-Kyle


See More: remove .doc if .docx exists with same name?

Report •


#1
March 21, 2011 at 13:34:23
Script version (untested):
for %%a in (*.docx) do del "%%~Na.doc"

How To Ask Questions The Smart Way


Report •

#2
March 21, 2011 at 13:51:51
One more thing. If filename1.docx exists and filename1(1).docx exist or even filename1(32).docx exist then delete all encounters of filename1(1-99).docx

Report •

#3
March 21, 2011 at 13:56:21
Is filename1.docx guaranteed to exist if filename1(1-99).docx exists?

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
March 21, 2011 at 14:03:36
Wow this is way more difficult than I thought. All my conversions were saved into a converted folder but it appears to only be 1 directory deep.

So I will have like my /mainfolder/converted folder for all the docs in the mainfolder

then I will have my /mainfolder/subfolder/converted for all the docs in the subfolder

how ever I will not have /mainfolder/subfolder/subfolder/converted because the directory structure is kept in tact in the /mainfolder/subfolder/converted folder

so some how I need to move all the content of all /converted/ folders to their parent directies.

then I need to delete all the accidental copies the ofc.exe program made.

then I need to do a file comparison and directory structor comparison to make sure everything lines up correctly for the final copy and no files are lost.

Does anyone have a more modern and easier solution where I can just convert all the current office 97-2003 files to office 2007?

thanks again,
-Kyle


Report •

#5
March 21, 2011 at 14:04:09
Is filename1.docx guaranteed to exist if filename1(1-99).docx exists?

Yes


Report •


Ask Question