Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram registry router security server slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Solved: How to change all files to zero-byte?

Reply  
Thread Tools
auaa's Avatar
Computer Specs
Junior Member with 2 posts.
 
Join Date: Feb 2010
Experience: Computer Illiterate
02-Feb-2010, 11:27 AM #1
Solved: How to change all files to zero-byte?
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.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Feb-2010, 11:29 AM #2
If you are doing it in pure batch you would have to delete the existing file first and then create a new file with the same name that is zero byte.

Use a For Loop with the dir command to parse the directory to get the filenames and delete the old and create a new one with the same name.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Feb-2010, 11:56 AM #3
This should work
Code:
@ECHO OFF
:: set your folder name here.
set _folder=E:\Zero byte files
pushd %_folder%
FOR /F "Tokens=*" %%I In ('Dir /a-d /b') Do (copy /Y nul "%%I")
popd
auaa's Avatar
Computer Specs
Junior Member with 2 posts.
 
Join Date: Feb 2010
Experience: Computer Illiterate
03-Feb-2010, 01:35 AM #4
Quote:
Originally Posted by Squashman View Post
This should work
Code:
@ECHO OFF
:: set your folder name here.
set _folder=E:\Zero byte files
pushd %_folder%
FOR /F "Tokens=*" %%I In ('Dir /a-d /b') Do (copy /Y nul "%%I")
popd
Thanks for helping Squashman, that codes really works !!

Thank you.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:26 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.