Page 1 of 2

Copying files as zero byte files

Posted: 29 Jan 2006, 11:15
by Tim
This is what I'd like to do:
- Copy files or a directory structure with files.
- The target files should all be zero byte files.
- Target directory structure and target file names should be identical.

Is this possible?
Is there a mask for this?

Thanks for any help in advance!

Re: Copying files as zero byte files

Posted: 29 Jan 2006, 14:31
by Jan Rysavy
Tim wrote:- The target files should all be zero byte files.
This is a small complication, but we can get over it.

1) Copy your directory using the Copy (F5) command
2) Go to the target directory, open Find window (Alt+F7), and find all files
3) In the Find window select all found files (Ctrl+A)
4) Open User Menu (F9) and choose your prepared command TRIM.

How to prepare the TRIM command:
1) Create a zero file in your working directory (C:\Work\zero.txt)
2) Options > Configuration > User Menu
3) Insert a new command TRIM, please look at following screenshot.

Image

Posted: 29 Jan 2006, 15:14
by Tim
Dear Jan,

Thank you very much indeed.
Děkuju!

What a quick and professional support. Amazing.
Works like a charm!

(If you find the time.... Could you explain what actually happens? So far it seems like magic. I assume that every file is overwritten with the contents of the file zero.txt. Correct? Is it normal that the file zero.txt exists in every directory after the operation is carried out?)

Best wishes
Tim

Posted: 29 Jan 2006, 17:06
by Jan Rysavy
Tim wrote:Is it normal that the file zero.txt exists in every directory after the operation is carried out?
In step (2) when the Find window is opened, click the Advanced button and clear the Directory attribute option. Then only files will be found.

Is it OK now?

Posted: 29 Jan 2006, 18:36
by Tim
Thanks for your reply, Jan.
Followed your instructions.
There's still a file called zero.txt in every directory.
But this is no problem as I can delete all the zero.txt files using the search function.
The main issue is solved for me.

Thanks again!

Posted: 29 Jan 2006, 19:26
by Jan Rysavy
Tim wrote:There's still a file called zero.txt in every directory.
Strange.

Please try to clear Options > Configuration > User Menu > TRIM > Close shell window option.

After TRIM command will be executed, the command shell should stay on your desktop. Could you please show me the output (use copy&pase from command shell window)?

It should look like this:

D:\testdir>call copy "c:\work\zero.txt" "test2.txt"
1 file(s) copied.

D:\testdir\dir>call copy "c:\work\zero.txt" "test1.txt"
1 file(s) copied.

D:\testdir\dir>

Posted: 29 Jan 2006, 22:27
by Tim
Sorry, my mistake.
Unchecked the Directory option after I had done the search.
Repeated the process in the correct order.
Now everything's just perfect.
Many THX!

Re: Copying files as zero byte files

Posted: 29 Jan 2006, 22:54
by jis
Tim wrote:This is what I'd like to do:
- Copy files or a directory structure with files.
- The target files should all be zero byte files.
- Target directory structure and target file names should be identical.

Is this possible?
Is there a mask for this?

Thanks for any help in advance!
I sometimes need copy of the directory structure too, but without files. I am just curious here: Why you need it including zero lenght files?

Re: Copying files as zero byte files

Posted: 29 Jan 2006, 23:06
by jis
Jan Rysavy wrote:
Tim wrote:- The target files should all be zero byte files.
This is a small complication, but we can get over it.

1) Copy your directory using the Copy (F5) command
2) Go to the target directory, open Find window (Alt+F7), and find all files
3) In the Find window select all found files (Ctrl+A)
4) Open User Menu (F9) and choose your prepared command TRIM.

How to prepare the TRIM command:
1) Create a zero file in your working directory (C:\Work\zero.txt)
2) Options > Configuration > User Menu
3) Insert a new command TRIM, please look at following screenshot.
...
And what about, if you have need preserve original time stamps of zeroed files?
Do you have any idea?

Re: Copying files as zero byte files

Posted: 30 Jan 2006, 07:10
by Jan Rysavy
jis wrote:I sometimes need copy of the directory structure too, but without files.
Please look at http://forum.altap.cz/viewtopic.php?t=149

Re: Copying files as zero byte files

Posted: 30 Jan 2006, 07:46
by jis
Jan Rysavy wrote:
jis wrote:I sometimes need copy of the directory structure too, but without files.
Please look at http://forum.altap.cz/viewtopic.php?t=149
Thanks, it works very well, but why pass thru the exclusion mask |* just only folders, not any files? Any logical explanation?

Re: Copying files as zero byte files

Posted: 30 Jan 2006, 09:04
by Jan Rysavy
jis wrote:Thanks, it works very well, but why pass thru the exclusion mask |* just only folders, not any files? Any logical explanation?
I thought, you need copy directory structure only? The |* is used to filter files out.

Re: Copying files as zero byte files

Posted: 30 Jan 2006, 09:17
by Jan Rysavy
jis wrote:And what about, if you have need preserve original time stamps of zeroed files?
Do you have any idea?
No idea under Windows command shell. In UNIX shell it will be piece of cake.

Under Windows I would make a small command line application for this task: take a filename as parameter, truncate it, preserve date/time/attributes.

Posted: 30 Jan 2006, 12:08
by Tim
@ jis

I use zero byte files for mirroring/managing FTP directory structures.

Re: Copying files as zero byte files

Posted: 30 Jan 2006, 21:11
by jis
Jan Rysavy wrote:
jis wrote:Thanks, it works very well, but why pass thru the exclusion mask |* just only folders, not any files? Any logical explanation?
I thought, you need copy directory structure only? The |* is used to filter files out.
Oh Jan, you misunderstand me :)
I was too brief in my question...
Sorry for this.

I learned about |* mask from this great forum and I started using this mask to filter out files and to copy only folders in my workflow just before this thread started.

Before I learn this trick I use my own script for cloning selected directory structure without files:

Code: Select all

xcopy.exe "$(Name)" "$(FullPath).Clonned directory structure" /t /e /y
What I really ask you is: Why this |* mask work as work? I think that folders are only special case of files in filesystem, so how this filter really works? Does it work only as side effect of something?