简体   繁体   中英

Use echo to empty file content in Windows Command Prompt

I have a folder on a windows laptop running a program for measuring concrete vibrations that runs 24/7. The software creates 2 files every 10 minutes *.asx and *.pbx The *.pbx files becomes 28 MB each. I run backup from the laptop to an ftp server every night. I would need to empty the files of its data, tried with echo and that works. but its thousands of files and i cannot figure out how to do it on all *.pbx extensions. Cannot remove the files, because then program will then restart the number sequence after 10 min. I need to keep all files in the directory just need to shrink them. The data in the files are not important after backup is finished.

I have tried echo delete >*.pbx and most of the arguments.

Please help!

To empty a file, you can use copy:

copy /Y nul: myfile.myext

Use FOR /F - loop command: against the results of another command .

From command prompt:

for /f "delims=" %G in ('dir /B *.pbx') do @copy /Y NUL "%~G">NUL

From a Windows batch script ( .bat or .cmd )

@for /f "delims=" %%G in ('dir /B *.pbx') do @copy /Y NUL "%%~G">NUL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM