How to zero size all files in a folder

Page 1 of 2 12 LastLast
  1. stub's Avatar
    Posts : 110
    Win10 v20H2 Build 19042.804
       #1

    How to zero size all files in a folder


    How to zero size all files in a specific folder. And then continuing on, how do I zero any new files placed in that folder in the future.
      My Computer

  2. pepanee's Avatar
    Posts : 1,462
    Windows 10 Professional
       #2

    I don't understand fully what you're doing. Please refer to the picture. Is this what you want?

    How to zero size all files in a folder-image.png
      My Computer

  3. stub's Avatar
    Posts : 110
    Win10 v20H2 Build 19042.804
    Thread Starter
       #3

    Yes. But I need to retain the domain name. So if your depiction is meant to represent the original domain names. This is correct.

    But after this has been completed. There will be other files added which won't have zero file sizes. And I'd like some method of zeroing the size of those files too.
      My Computer

  4. bro67's Avatar
    Posts : 8,359
    Mac OS Catalina
       #4

    stub said:
    Yes. But I need to retain the domain name. So if your depiction is meant to represent the original domain names. This is correct.
    But after this has been completed. There will be other files added which won't have zero file sizes. And I'd like some method of zeroing the size of those files too.
    First there is no domain name in the file naming scheme. Second it would mess up the File Table and MBR, if it saw zero sized files.
      My Computers


  5. Posts : 1,300
    X
       #5

    What is your purpose for doing this?
      My Computer


  6. Posts : 810
    Win10
       #6

    There's no problem with 0-sized files on any filesystem I know of. Powershell can easily do this.

    Code:
    PS C:\temp\zero> dir
    
        Directory: C:\temp\zero
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        5/21/2018     23:14             14 www.google.com
    -a----        5/21/2018     23:14             17 www.microsoft.com
    -a----        5/21/2018     23:14             17 www.tenforums.com
    
    
    PS C:\temp\zero> dir | New-Item -Force -Value ""
    
        Directory: C:\temp\zero
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        5/21/2018     23:15              0 www.google.com
    -a----        5/21/2018     23:15              0 www.microsoft.com
    -a----        5/21/2018     23:15              0 www.tenforums.com
      My Computer

  7. stub's Avatar
    Posts : 110
    Win10 v20H2 Build 19042.804
    Thread Starter
       #7

    @bro67 - Sorry. I was tired when I sent my last reply. I'm sorry about that. Domain Name should be File Name. But I'm confused about what you say about the MBR and file table.

    @margrove55 - The purpose is I'm continually receiving new files into this folder, and when after I have processed them, I want to convert the original files in the folder to zero bytes, so that I cannot receive the same files twice and process them twice.

    @PolarNettles - What is Powershell? Does this come as part of Win10? I know I'm showing my noobness. If not. Where to get it. Is this the exact command I need to run or are these parameters only? And if so, What is the exact command line required to achieve this effect.

    And then to the second part of my question? How to zero-ize only the filenames which have file sizes, the next I time run the command. Is that even possible?
      My Computer


  8. Posts : 810
    Win10
       #8

    Powershell is built in to Win 10. You can write PowerShell scripts similar to batch files. There are tutorials and courses available online, such as Getting Started with PowerShell 3.0 Channel 9 .

    You can write the PS script to only zero out files with size > 0. This would be a good exercise as you are learning it.
      My Computer

  9. bro67's Avatar
    Posts : 8,359
    Mac OS Catalina
       #9

    You do not want to set file size to 0. It will mess up the MBR and File Tables. There is zero reason to even do what you are doing.
      My Computers


  10. Posts : 810
    Win10
       #10

    bro67 said:
    You do not want to set file size to 0. It will mess up the MBR and File Tables. There is zero reason to even do what you are doing.
    Please provide proof. Zero-sized files are used all the time . And why would the "file table" affect the MBR?

    Code:
    PS D:\> dir
    
    
        Directory: D:\
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        5/21/2018     23:21              0 www.tenforums.com
    -a----        5/21/2018     23:21              0 www.google.com
    
    
    PS D:\> chkdsk /offlinescanandfix
    The type of the file system is FAT32.
    Cannot lock current drive.
    
    Chkdsk cannot run because the volume is in use by another
    process.  Chkdsk may run if this volume is dismounted first.
    ALL OPENED HANDLES TO THIS VOLUME WOULD THEN BE INVALID.
    Would you like to force a dismount on this volume? (Y/N) y
    Volume dismounted.  All opened handles to this volume are now invalid.
    Volume NEW VOLUME created 5/20/2018 08:03
    Volume Serial Number is F8C1-E6AD
    Windows is verifying files and folders...
    File and folder verification is complete.
    
    Windows has scanned the file system and found no problems.
    No further action is required.
       15,338,496 KB total disk space.
                8 KB in 1 hidden files.
               16 KB in 4 files.
       15,338,464 KB are available.
    
            8,192 bytes in each allocation unit.
        1,917,312 total allocation units on disk.
        1,917,308 allocation units available on disk.
    PS D:\> Get-Volume -DriveLetter D
    
    DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining     Size
    ----------- ------------ -------------- --------- ------------ ----------------- -------------     ----
    D           NEW VOLUME   FAT32          Removable Healthy      OK                     14.63 GB 14.63 GB
      My Computer


 
Page 1 of 2 12 LastLast

  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 22:11.
Find Us




Windows 10 Forums