ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Idea: File Resizer

(1/2) > >>

Ordstrin:
This is, I'll admit, an odd request.

I'd like a program that can resize a file to 0 bytes without deleting it or touching the file name.
A batch mode would also be exceedingly welcome.

The basic procedure I currently use (when I need to) is:
1) Open notepad.exe
2) drag & drop the file onto notepad
3) Select all & delete
4) Save changes

I'd love a program that can do this for me automaticallly though.
Yes I know there are much more efficient ways of going about this but...

Time for bed now, my peculiarities demand sleep also.

~Ordstrin

EDIT:

A few more requirements to go with this odd request.

a) The other files in the directory shouldn't be touched.
b) It should work on all file types (including executables).
c) I'm currently running a Windows system.

MilesAhead:
Just create a batch file in a folder in your Path.  In my case I named it zero.cmd.


--- ---@echo off
type nul > "%1"

To "zero" all .txt files in the current folder you can use a command prompt:

for %s in (*.txt) do zero %s

or you can make a .cmd file that uses shift to go through the command line args.
Linux shell stuff is generally better about command line globbing than Windows though.

You could probably do it with gnu win32 utilities using find.

scancode:
Just create a batch file in a folder in your Path.  In my case I named it zero.cmd.


--- ---@echo off
type nul > "%1"

To "zero" all .txt files in the current folder you can use a command prompt:

for %s in (*.txt) do zero %s

or you can make a .cmd file that uses shift to go through the command line args.
-MilesAhead (August 23, 2009, 05:33 PM)
--- End quote ---


--- ---for %s in (*.txt) do @nothing 1>%s 2>nul
The same, but doesn't require a second cmd file :)

MilesAhead:
Or do


--- ---for %s in (*.txt) do type nul > %s

and have no .cmd file at all.  That's how I'd do it if I was using command prompts.  In AutoIt3 or some other language that does easy Guis with drop targets just drag & drop and call a file write function to zero the files in the drop list.  Depends if you're primarily interested in batch... but the drop target gui, if the window is created dynamically, can just pass on creating the window if you have command line params for the files, and be dual purpose.


It's pretty trivial.

scancode:
Or do


--- ---for %s in (*.txt) do type nul > %s

and have no .cmd file at all.
-MilesAhead (August 23, 2009, 08:00 PM)
--- End quote ---

Mine didn't require a .cmd file either, but yours is a lot cleaner! Added to snippets list :Thmbsup:

Navigation

[0] Message Index

[#] Next page

Go to full version