{"record":{"id":"5b9aa987b07f869e","repo":"Tencent/matrix","slug":"there-is-no-second-file-name-for-rename-pair","errorCode":null,"errorMessage":"There is no second file name for rename pair:","messagePattern":"There is no second file name for rename pair:","errorType":"exception","errorClass":"CArcCmdLineException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp","lineNumber":489,"sourceCode":"    else if (renamePairs)\n    {\n      if (oldIndex == -1)\n        oldIndex = i;\n      else\n      {\n        // NRecursedType::EEnum type is used for global wildcard (-i! switches)\n        AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, NRecursedType::kNonRecursed, wildcardMatching);\n        // AddRenamePair(renamePairs, nonSwitchStrings[oldIndex], s, type);\n        oldIndex = -1;\n      }\n    }\n    else\n      AddNameToCensor(censor, s, true, type, wildcardMatching);\n  }\n  \n  if (oldIndex != -1)\n  {\n    throw CArcCmdLineException(\"There is no second file name for rename pair:\", nonSwitchStrings[oldIndex]);\n  }\n}\n\n#ifdef _WIN32\n\nstruct CEventSetEnd\n{\n  UString Name;\n  \n  CEventSetEnd(const wchar_t *name): Name(name) {}\n  ~CEventSetEnd()\n  {\n    NSynchronization::CManualResetEvent event;\n    if (event.Open(EVENT_MODIFY_STATE, false, GetSystemString(Name)) == 0)\n      event.Set();\n  }\n};\n","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-backtrace/src/main/cpp/external/libunwindstack/deps/liblzma/CPP/7zip/UI/Common/ArchiveCommandLine.cpp#L471-L507","documentation":"When the -snr / rename-pair parsing mode is active (renamePairs != NULL), AddToCensorFromNonSwitchesStrings consumes path arguments in pairs (old name, new name). After the loop, if an odd number of rename arguments was supplied (oldIndex is still set but its partner was never provided), the parser throws \"There is no second file name for rename pair:\" naming the unmatched first file.","triggerScenarios":"Invoking a rename operation (e.g. 7z rn archive.7z oldname with only one name, or an odd count of positional names) so that the last old-name has no matching new-name, at ArchiveCommandLine.cpp:489 via CArcCmdLineParser::Parse2.","commonSituations":"Renaming a file inside an archive with 7z rn but forgetting the second argument; a shell variable holding the new name being empty so the pair collapses to one argument; scripted batch renames where an odd element count slips through.","solutions":["Supply both the old and new file name for each rename pair: 7z rn archive.7z <old_name> <new_name>.","Check the argument count is even for the rename command before running it.","Fix scripts so the new-name variable cannot be empty (use ${NEW_NAME:?} style guards).","If renaming many files, verify each pair in the generated command text."],"exampleFix":"// before\n7z rn archive.7z docs/old.txt\n// after\n7z rn archive.7z docs/old.txt docs/new.txt","handlingStrategy":"validation","validationCode":"if (renameArgs.length % 2 !== 0 || renameArgs.some(a => !a || a.length === 0)) throw new Error('rename requires an even number of non-empty (old, new) path arguments');","typeGuard":"const isEvenPairs = (xs) => Array.isArray(xs) && xs.length % 2 === 0 && xs.every(x => typeof x === 'string' && x.length > 0);","tryCatchPattern":"try { parser.parse2(argv); } catch (e) { if (String(e.message).startsWith('There is no second file name for rename pair:')) { /* report the unmatched pair name from e.message */ } else throw e; }","preventionTips":["Always pass rename operations as explicit (old, new) pairs and assert the count is even first.","Guard the new-name variable against being empty in scripts.","Echo the generated command line for review before executing batch renames.","Prefer a wrapper function renamePair(archive, oldName, newName) over raw argument arrays."],"tags":["cli","missing-argument","rename-pair"],"backgroundTag":"missing-required-argument","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}