Copying files as zero byte files

We welcome any suggestions for new features or improvements in Altap Salamander. Please post one suggestion per report.
Tim
Posts: 46
Joined: 28 Jan 2006, 13:28
Location: Berlin

Copying files as zero byte files

Post 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!
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Copying files as zero byte files

Post 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
Tim
Posts: 46
Joined: 28 Jan 2006, 13:28
Location: Berlin

Post 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
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Post 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?
Tim
Posts: 46
Joined: 28 Jan 2006, 13:28
Location: Berlin

Post 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!
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Post 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>
Tim
Posts: 46
Joined: 28 Jan 2006, 13:28
Location: Berlin

Post 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!
User avatar
jis
Posts: 451
Joined: 27 Jan 2006, 23:14
Location: Prague, Czech Republic

Re: Copying files as zero byte files

Post 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?
User avatar
jis
Posts: 451
Joined: 27 Jan 2006, 23:14
Location: Prague, Czech Republic

Re: Copying files as zero byte files

Post 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?
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Copying files as zero byte files

Post 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
User avatar
jis
Posts: 451
Joined: 27 Jan 2006, 23:14
Location: Prague, Czech Republic

Re: Copying files as zero byte files

Post 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?
Altap Salamander fan since 1998
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Copying files as zero byte files

Post 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.
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Copying files as zero byte files

Post 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.
Tim
Posts: 46
Joined: 28 Jan 2006, 13:28
Location: Berlin

Post by Tim »

@ jis

I use zero byte files for mirroring/managing FTP directory structures.
User avatar
jis
Posts: 451
Joined: 27 Jan 2006, 23:14
Location: Prague, Czech Republic

Re: Copying files as zero byte files

Post 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?
Altap Salamander fan since 1998
Post Reply