Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Renaming file in archive

Mike
2014-01-18
2014-01-18
  • Mike
    Mike
    2014-01-18

    I need to compress 3 files, one of which is always an XML file, and always needs to use the same name, like XML.xml. I don't always know the name of the input file. Is there a way to use the rn command along with a wildcard to rename all *.xml files in an archive like XML.xml? There should only be one xml file in the archive, so I'm not worried about naming collisions on multiple xml files.

    Or alternatively, is there a way to name all *.xml files xml.xml upon the original compression? That way I don't need to worry about a 2nd renaming process.

     
  • Shell
    Shell
    2014-01-18

    Renaming the file in the archive doesn't work for wildcards yet (or I have tried it the wrong way). Renaming the file on the disk:
    ren path\*.xml XML.xml
    If you need the original name, then the code becomes more complex:
    for %%a in (*.xml) do set oldname=%~na
    ren path\*.xml XML.xml
    7z ...
    ren path\\XML.xml %oldname%.xml