1

I have a folder on a Windows Server full of DLL's that get created nightly. Sometimes something goes wrong with the nightly job and instead of the DLL's being overwritten with new versions, the new version gets created as a versioned file with a (1) suffixed in the last part of the filename. E.g. "apple.dll" now gets a duplicate file of "apple (1).dll".

How do a rename all files in this folder using the Windows command "ren" and wildcards to drop the " (1)" part of the filename? I've already deleted all the old files without the 1 attached as those I could isolate by date modified in Windows Explorer.

I've tried "ren *(1).dll *.dll" but nothing happens. Tried similer in Power Shell but just get this error: "Cannot process argument because the value of argument "path" is not valid. Change the value of the "path"."

If the Windows command "rename" nor the Power Shell rename-item commandlet can't do this, I'm open to other suggestions.

Thanks in advance

  • You won't be able to do with those tools in one simple command. For PowerShell use Get-ChildItem to find those files, create a variable with the ` (1)` part for the named removed and pass the item and new filename to Rename-item. – Seth Sep 15 '17 at 8:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.