Link to home
Start Free TrialLog in
Avatar of Rabih El Haj youssef
Rabih El Haj youssefFlag for Australia

asked on

How to find all zero-byte files in a directory including subdirectories from Command Line ?

How to find all zero-byte files in a directory including subdirectories from Command Line
Look like our file server is affected with virus.
We would like to export all the entire 0KB size files from our server that has hundreds if not thousands of sub-directories and contain files with 0 KB.
Is there a way to do this from the command line?
Prefer a script to export all of them to CSV file. Including the name of the file, Location and date if possible.
Could you please tell me what causing these file to get corrupted with 0KB. How can we fix that or find the route of this issue.

Thank you in advance
ASKER CERTIFIED SOLUTION
Avatar of Omar Soudani
Omar Soudani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rabih El Haj youssef

ASKER

Hi Omar ,

Thank you very much , it works .

do you know what causing these files to get corrupted ?

also if I want to add  some attribute like date and ETC and with nice format . is that possible please?
You can echo the date and time along with the path to each of the files by adding @fdate and @ftime variables before or after the @path.

https://ss64.com/nt/forfiles.html

For example, to output as a CSV that could be opened in Excel, you could first add a header in your command:
echo FileName,Date,Time,FilePath>list.csv
then in your FORFILES command you could separate the output fields with commas like this:
echo @file,@fdate,@ftime,@path>>list.csv