How to change all files to zero-byte?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
auaa
Posts: 2
Joined: 02 Feb 2010 09:15

How to change all files to zero-byte?

#1 Post by auaa » 02 Feb 2010 09:27

Hi, is there any way I can change all files in a folder to zero-byte length? I need to have the same filenames, just want to change their size to zero. Maybe by creating a batch file.

Please help. Thanks.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to change all files to zero-byte?

#2 Post by aGerman » 02 Feb 2010 11:27

auaa

no idea what those could be good for :?:
Take a FOR loop and overwrite each file with 0 byte.

Code: Select all

@echo off &setlocal
set "folder=C:\anywhere"

pushd "%folder%"||goto :eof
for %%a in (*) do (
  type nul>"%%a"
)
popd


Every found file will be a blank file, also links!

Regards
aGerman

auaa
Posts: 2
Joined: 02 Feb 2010 09:15

Re: How to change all files to zero-byte?

#3 Post by auaa » 02 Feb 2010 23:13

Thanks a lot aGerman, you made my day brighter. :D
That is the codes that I looked for. It works !! :P

Actually, I have a program that always update/download new files into certain folders. Eventhough I deleted the old (not-needed files), but this program will always download the same files that I already deleted. That is why I need a way to make the files to zero-byte. This program will still see the files are availalable (although with zero byte), and it will not download the same files into this folder.

Thanks again.

Post Reply