How to move sparse file maintening the real sparse dimensions


  1. Posts : 192
    Window 10 Home 20H2 x64 (build SO 19042.1052)
       #1

    How to move sparse file maintening the real sparse dimensions


    Hi everyone,

    I need to move "sparse" files from one disk to another. Both ntfs obviously.

    I want the size occupied on the target disk to be the same as the source disk. So not the final dimension but the "sparse" dimension.

    How can I solve it?

    EDIT: I would like to make a script to move only files from a certain maximum size down.
    Last edited by einstein1969; 23 Jul 2020 at 08:17.
      My Computer


  2. Posts : 27,646
    Windows 10 Pro x64 Version 21H1
       #2

    Have you looked in Robocopy?

    It has a parameter /MIN:n which excludes files smaller than "n" in size.

    or /MAX:n which excludes files larger than "n"


    Not sure about how it handles Sparse files, you could experiment.
      My Computer


  3. Posts : 2,799
    Windows 11 Pro, 22H2
       #3

    @einstein1969,

    Unless I'm way off base, my understanding is that if you copy or move a sparse file from one NTFS volume to another NTFS volume, the sparse file will remain a sparse file. Have you actually tried this as a test to see if that is the case?
      My Computers


  4. Posts : 192
    Window 10 Home 20H2 x64 (build SO 19042.1052)
    Thread Starter
       #4

    I have tried dos command "move", "robocopy", "CS.exe" command . Nothing of this work.

    This is the script that have made for my "emule" .part file sparse.

    Code:
    @echo off & setlocal ENABLEDELAYEDEXPANSION
    
    echo ATTENZIONE se i file esistono li sovrascrive!
    
    pause
    
    rem da fare: log
    
    rem Attenzione: il comando "move" sposta il file e non mantiene il flag sparse!
    
    Echo Sposta i file piccoli
    
    rem 2G , massimo 2^31-1
    set "big=2000000000"
    
    rem commentare questo "set" per numeri non big
    rem 18G , diviso per 10 , uno zero in meno
    set "big2=1800000000"
    
    set "sourcedir=D:\emule_temp\Temp\"
    
    set "destdir=C:\Users\fposc\Downloads\eMule\Temp\"
    
    cd /D "%sourcedir%"
    
    Set /A I=1
    for /f "tokens=*" %%A in ('dir *.part /b') do (
    
    	for /f "tokens=3" %%F in ('dir %%A ^|findstr %%A') do set "dim=%%F"
    
    	echo(
    	echo(!time! - File %%A , dim: !dim! - [%%~zA] , nome: %%~nA , ext: %%~xA , comp: %%~fA
    	echo(
    
    	if defined big2 (
    		:: Trick per big num
    		set "num=%%~zA"
    		set "numn=!num:~0,-1!"
    		if !numn! lss %big2% ( 
    			echo Sposto:
    			dir /b %%A.*
    			rem move %%A.* "%destdir%"
                            robocopy . "%destdir%\" %%A.* /J /MOV /MT:1 /BYTES /ETA /NJH /NJS
    			:: reimposto lo sparse
    			fsutil sparse setflag "%destdir%%%A"
    			fsutil sparse queryflag "%destdir%%%A"
    			echo(
    			choice /T 8 /C SN /D S /M "Vuoi continuare con il prossimo file? Hai 8 secondi per decidere [Predefinito S]:"
    			if errorlevel 2 ( echo Interrompo. & pause & exit/b )
    		)
    	) else (
    
    		if %%~zA lss %big% (
    			echo Sposto:
    			dir /b %%A.*
    			move %%A.* %destdir%
    			:: reimposto lo sparse
    			fsutil sparse setflag "%destdir%%%A"
    			fsutil sparse queryflag "%destdir%%%A"
    			echo(
    			choice /T 8 /C SN /D S /M "Vuoi continuare con il prossimo file? Hai 8 secondi per decidere [Predefinito S]:"
    			if errorlevel 2 ( echo Interrompo. & pause & exit/b )
    
    		)
    	)
    )
    pause
    exit/b
    But not work. It mark a file sparse but after move.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 00:41.
Find Us




Windows 10 Forums