Menu

#1519 Duplicate filenames on extraction - windows command-line version

open
nobody
duplicates (1)
5
2015-05-28
2015-05-18
Mysteron347
No

When a file with a long filename is extracted, it may create an alias 8.3 filename which matches a filename to be extracted later from the archive.

If the 8.3 filenames were extracted first and the long filenames extracted as a second phase, this problem could be averted.

Discussion

  • Shell

    Shell - 2015-05-18

    8.3 filenames are created by OS, not by 7-Zip itself. Such names often look like FILENA~1.TXT, which almost always guarantees they will not match meaningful filenames. Do you have an example of the contrary?

    It is possible to make 7-Zip delete the short name, but I think this matter should be handled by the OS.

     
  • Anonymous

    Anonymous - 2015-05-20

    facing exact same issue :(
    fixed it :)
    link

     

    Last edit: Anonymous 2015-05-25
  • Gauthier Van Vreckem

    https://support.microsoft.com/en-us/kb/121007
    To disable 8.3 name creation on all NTFS partitions, type fsutil.exe behavior set disable8dot3 1 at an elevated command prompt, and then press Enter.

    you can also disable it on a specific partition.

     
  • Mysteron347

    Mysteron347 - 2015-05-28

    Here's a batchfile I used for testing:

    @ECHO OFF
    SETLOCAL
    
    :: U: is my RAMdrive
    
    SET "destdir=U:\demo"
    :: create the destination directory and empty it
    MD "%destdir%" >NUL 2>NUL
    DEL "%destdir%\?*?"
    :: Temporarily switch to newly-created/cleared directory
    :: generate 2 files
    FOR /L %%a IN (1,1,2) DO (
     DIR >"%destdir%\demons~%%a.txt"
    rem DIR >"%destdir%\delivery~%%a.txt"
    )
    DIR >"%destdir%\demonstrate1.txt"
    DIR >"%destdir%\demonstration1.txt"
    :: archive them
    7z a "%destdir%\archive" "%destdir%\d*"
    :: show directory
    DIR /x %destdir%
    :: delete the d* files
    DEL "%destdir%\d*"
    :: show directory
    DIR /x %destdir%
    :: un-archive.
    ::
    :: The lfn file is extracted first and windows creates an sfn alias
    :: which exactly matches the filename of the second file to be extracted.
    ::
    pushd %destdir%
    7z e "%destdir%\archive.7z"
    ::
    :: Extracting the 8.3 filenames as a first pass and then the remaining files
    :: as a second pass would prevent this from happening
    ::
    :: show directory
    DIR /x %destdir%
    :: back to original directory
    popd
    
    GOTO :EOF
    

    *** Notes: My U: drive is a 2Gb FAT Ramdrive.

    *** This particular batch has never failed, but have found similar batches attempting to extract from an archive where a shortfilename is generated which matches the full filename of a filename to be extracted later in the archive.

    Now here's an astounding preculiarity:

    If I execute a series of commands from the prompt:

    pushd u:\demo&del d*&7z e archive.7z&popd&dir /x u:\demo
    pushd u:\demo&del d*&7z e "archive.7z"&popd&dir /x u:\demo
    pushd u:\demo&del d*&7z e "u:\demo\archive.7z"&popd&dir /x u:\demo
    pushd u:\demo&del d*&7z e u:\demo\archive.7z&popd&dir /x u:\demo
    u:
    cd \
    (then the above sequence of 4 lines again)
    cd \demo
    (then the above sequence of 4 lines again)
    del d*&7z e archive.7z&dir /x u:\demo
    del d*&7z e "archive.7z"&dir /x u:\demo
    del d*&7z e "u:\demo\archive.7z"&dir /x u:\demo
    del d*&7z e u:\demo\archive.7z&dir /x u:\demo
    

    Then it sometimes works - and sometimes fails, with no apparent pattern. I've tried different times-of-day, starting a fresh cmd.exe instance, having multiple cmd.exe instances and have been unable to discern a pattern.

    Sadly, mr. kim's link above fails for me. I'm aware that "echo u|7z e archive.7z" will overcome the problem - but by auto-renaming the sfns. (I'd suggest a switch (-au?)) to control automatic-accept-renaming)

    Perhaps

    (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit?

    could be extended to

    (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit
    (K)ey in new name / (R)eplace with autogeneratednewname ?

    Where K would allow a new name to be keyed in from the keyboard and R would extract the file to a new name "autogeneratednewname" for this file only, unlike U which accepts the auto-geenrated new name for all clashing filenames.

     
  • Shell

    Shell - 2015-05-28

    Nobody argues that there is such a problem. The fact is that filenames like demons~1.txt do not usually appear in archives. In my opinion, this behavior with short names needs not to be fixed, at least in 7-Zip.

    As for manual renaming, I think it might be a useful feature.

     

Log in to post a comment.

MongoDB Logo MongoDB