Jump to content

Paste over, a structure of folders without overwriting files?


horus

Recommended Posts

I want to paste over structure of folders "A", another structure of folder, called "B".

How can I do it without overwriting any of the files from structure "A"?

I want to move all the files from structure B, to structure A, except the ones that would cause overwriting.

Link to comment
Share on other sites


Are you sure that it is going to work?

Will it move only the files that won't cause overwriting?

/T Create folder structure, but do not copy files. Do not

include empty folders or subfolders.

/E Copy folders and subfolders, including Empty folders.

/I If in doubt always assume the destination is a folder

e.g. when the destination does not exist.

Link to comment
Share on other sites

Other than the above, you may use the Windows Cut/Paste. What is the problem? You can always click "NO" when it prompts for overwriting. Is the structure "A" too big?

--

Best Regards,

DreamsCentral

Twitter: @DreamsCentral

Signed: Wednesday, November 11, 2009, 3:03:23 PM IST

Link to comment
Share on other sites

Structure A is like this:

C:\\A\1\1\1

C:\\A\1\1\2

.....

C:\\A\1\1\100

C:\\A\1\2\1

C:\\A\1\2\2

....

C:\\A\1\2\100

Structure B is similar, and of course, WinXP's cut/paste doesn't work well, because it will overwrite all the files, or it won't copy more than one folder level[when clicking No for overwriting].

Link to comment
Share on other sites

Try this horus ...

We'll call the finished product C ...

Copy folder A to new folder C

Copy B into C (and click YES to all)

Copy A into C (and click YES to all)

Done! B is integrated with A preserved. Delete A and B for cleanup.

Its kind of like an XOR. This is an often needed procedure in an infinite number of areas, and most dedicated tools make it too complicated. Besides, IMHO this is the fastest way.

Link to comment
Share on other sites

Try this horus ...

We'll call the finished product C ...

Copy folder A to new folder C

Copy B into C (and click YES to all)

Copy A into C (and click YES to all)

Done! B is integrated with A preserved. Delete A and B for cleanup.

Its kind of like an XOR. This is an often needed procedure in an infinite number of areas, and most dedicated tools make it too complicated. Besides, IMHO this is the fastest way.

Interesting trick, however, I think that there's a problem.

I'm interested to integrate B with A, without overwriting, but I'm also interested to separate the files from B that would cause overwriting.

The algorithm is like this, move all the files, along with their folder structure, from B to A, as long as they don't cause any overwriting.

In the end, I'll get a beefed up, structured A, and a skinny B, containing only the files that would cause overwriting, along with their folder structure.

About "No to all trick", I believe we can agree that it only works at the first level of subfolders, right?

It doesn't check deeper into the folder structure.

Link to comment
Share on other sites

horus, let me ask you, is this folder merge is a on-time task or an ongoing procedure?

If this is something ongoing that you will need to do often and consistently then you will want a programmable solution, and I would suggest a lightweight file synchronization utility (keyword is sync).

If this is some one-off job it can be easily done as I stated above but with an added step to address what you stated in this reply ...

Interesting trick, however, I think that there's a problem.

I'm interested to integrate B with A, without overwriting, but I'm also interested to separate the files from B that would cause overwriting.

The algorithm is like this, move all the files, along with their folder structure, from B to A, as long as they don't cause any overwriting.

In the end, I'll get a beefed up, structured A, and a skinny B, containing only the files that would cause overwriting, along with their folder structure.

First, let me point out a possible flaw in that algorithm. If you make any edits to B they will get lost with this strategy. In other words, you better be sure that there are no files in B that are newer/better than identically named files in A.

Secondly, please note that this is a safe method. This suggestion does not involve a move when a copy plus delete can be used instead, this is due to the small but still existing element of risk of data loss in the middle of the operation should the power fail (yes, I know that NTFS is journaled, but I always play it safe!) If you want to use a Move or Xcopy with a switch, then this suggestion is not for you. Here we go:

Copy folder A to new folder C

Copy B into C (and click YES to all)

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

We are now half done per your requirements, now we just need to skinny down folder B by deleting files that are identical to the now fatter A. The next step requires a shortcut icon to WinDiff, I keep one in QuickLaunch.

Grab both Folders A and B and drop them on WinDiff.

In Windiff, click options and make sure that Show Identical Files is checked. The other three options: Left-Only and Right-Only and Show Different Files must be unchecked. Ok? Now the list shows the filenames with folder paths pre-pended of every file that needs to be deleted from B.

This list needs to be pasted into an editor and then fixed up for use as a batch file. If you don't know how: Single-Click the first file, hold down the Shift and Ctrl keys, press the End key, the entire list should be selected (release keys). Ctrl-C copy to clipboard, paste this into your editor. Two fix-ups are necessary (beginning and end of each line).

Beginning of each line ... Search-Replace the string directly preceding the first FilePath, usually 3 chars: <space><tab><dot> and substitute it with DEL and your exact FilePath to the Folder B like so: del "C:\B

End of each line ... Search-Replace each LineFeed and substitute "LineFeed (for example in UltraEdit each ^p becomes "^p

Example here to make it crystal clear ... let's say this is the raw list from WinDiff ...

[color="#FF0000"] 	[color="#000000"].\[/color]1\1\$$$5.reg
[color="#000000"].\[/color]1\1\(((.reg
[color="#000000"].\[/color]1\1\---.txt
[color="#000000"].\[/color]1\1\1.b64
[color="#000000"].\[/color]1\1\1.xap
[color="#000000"].\[/color]1\1\100_2013-15.jpg
[color="#000000"].\[/color]1\1\100_2013.jpg
[color="#000000"].\[/color]1\1\100_2014.jpg
[color="#000000"].\[/color]1\1\2.b64
[color="#000000"].\[/color]1\1\2.xap
[color="#000000"].\[/color]1\1\3.b64
[color="#000000"].\[/color]1\1\3.xap
[color="#000000"].\[/color]1\1\4.b64
[color="#000000"].\[/color]1\1\4.xap
[color="#000000"].\[/color]1\1\85888067.jpg
[color="#000000"].\[/color]1\1\@.htm
[color="#000000"].\[/color]1\1\^$#.txt
[color="#000000"].\[/color]1\1\_k_2.txt
[color="#000000"].\[/color]1\1\_k_4.txt
[color="#000000"].\[/color]1\1\_rar.bat
[color="#000000"].\[/color]1\1\ddd.htm
[color="#000000"].\[/color]1\1\debugtrace.log
[color="#000000"].\[/color]1\1\deltree.pif
[color="#000000"].\[/color]1\1\dvd_win7_1_1.xap
[color="#000000"].\[/color]1\1\dvd_win7_1_2.xap
[color="#000000"].\[/color]1\1\dvd_win7_1_3.xap
[color="#000000"].\[/color]1\1\dvd_win7_1_4.xap
[color="#000000"].\[/color]1\1\edit1.html
[color="#000000"].\[/color]1\1\file01
[color="#000000"].\[/color]1\1\filelist.dat
[color="#000000"].\[/color]1\1\firmtools_test_panorama.jpg
[color="#000000"].\[/color]1\1\get.htm
[color="#000000"].\[/color]1\1\listst.txt
[color="#000000"].\[/color]1\1\macro.txt
[color="#000000"].\[/color]1\1\macrooo.txt
[color="#000000"].\[/color]1\2\page_47_d.jpg
[color="#000000"].\[/color]1\2\page_47_d_steg.jpg
[color="#000000"].\[/color]1\2\page_52_h.jpg
[color="#000000"].\[/color]1\2\page_53_a.jpg
[color="#000000"].\[/color]1\2\page_53_j-ic.jpg
[color="#000000"].\[/color]1\2\page_53_j.jpg
[color="#000000"].\[/color]1\2\page_60_d1.jpg
[color="#000000"].\[/color]1\2\panotools_result0.0.psd
[color="#000000"].\[/color]1\2\ppp.htm
[color="#000000"].\[/color]1\2\prefs.js
[color="#000000"].\[/color]1\2\report.html
[color="#000000"].\[/color]1\2\rrrttt.txt
[color="#000000"].\[/color]1\2\rrtt.txt
[color="#000000"].\[/color]1\2\sss.txt
[color="#000000"].\[/color]1\2\temm.txt
[color="#000000"].\[/color]1\2\temp#@.txt
[/color]

Your edits should result in this ...

[color="#FF0000"][color="#000000"]del "C:\B[/color]\1\1\$$$5.reg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\(((.reg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\---.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\1.b64[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\1.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\100_2013-15.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\100_2013.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\100_2014.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\2.b64[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\2.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\3.b64[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\3.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\4.b64[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\4.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\85888067.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\@.htm[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\^$#.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\_k_2.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\_k_4.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\_rar.bat[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\ddd.htm[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\debugtrace.log[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\deltree.pif[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\dvd_win7_1_1.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\dvd_win7_1_2.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\dvd_win7_1_3.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\dvd_win7_1_4.xap[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\edit1.html[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\file01[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\filelist.dat[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\firmtools_test_panorama.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\get.htm[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\listst.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\macro.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\1\macrooo.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_47_d.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_47_d_steg.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_52_h.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_53_a.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_53_j-ic.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_53_j.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\page_60_d1.jpg[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\panotools_result0.0.psd[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\ppp.htm[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\prefs.js[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\report.html[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\rrrttt.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\rrtt.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\sss.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\temm.txt[color="#000000"]"[/color]
[color="#000000"]del "C:\B[/color]\1\2\temp#@.txt[color="#000000"]"[/color]
[/color]

The batch file is done (unless you have some file attributes to worry about! If so, respond back if you need to learn how to clear ReadOnly etc). Save it and run it. But remember, if you have any nagging questions, ask them first!

EDIT: needed Shift+Ctrl then End to select everything in a WinDiff window! Yes, believe it or not there is no Select All! But there is a File > Save File List ...

EDIT2: arrgh just noticed I misread what you said: and a skinny B, containing only the files that would cause overwriting. That means non-identical are left in place! All fixed now. Sorry for the mistake.

Edited by CharlotteTheHarlot
Link to comment
Share on other sites

I really appreciate your interest, and your willing to help CharlotteTheHarlot, your idea is clever, but it's way too complicated, as I have to do it ~20times.

There's this software, RichCopy, it should be able to do what I want, but I can't find any good explanations for its settings.

http://blogs.techrepublic.com.com/window-on-windows/?p=1210

For example:"Availability: Check if the file exists in destination. " What does this involve? A file having the same name or a file having the same name, identical bit by bit, same date stamp, etc.

I remember that I've done some tests with the program, and it seemed to do what I want, but when I went to real files......fiasco....it overwrote a few dozen....and ofc....I wasn't very happy about that.

LE:I'm testing TeraCopy right now. From my tests, I think that it's able to move structures of folders without overwriting existing files.

Someone please confirm[just to be double assured], before I'll do any stupid things on 20000+ files.

Edited by horus
Link to comment
Share on other sites

The algorithm is like this, move all the files, along with their folder structure, from B to A, as long as they don't cause any overwriting.

In the end, I'll get a beefed up, structured A, and a skinny B, containing only the files that would cause overwriting, along with their folder structure.

First, let me point out a possible flaw in that algorithm. If you make any edits to B they will get lost with this strategy. In other words, you better be sure that there are no files in B that are newer/better than identically named files in A.

I can't see how files in B would be overwritten here.

+

Copy folder A to new folder C

Copy B into C (and click YES to all)

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

What's the difference with this

Copy B into C

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

?

@Horus, are there files at higher level as well ? (like C:\A\whatever.dat)

if not, something as simple as this does it, but you have to answer N for each potential overwriting :}

FOR %%A in (1,2) DO FOR %%B in (1,2) DO FOR %%C in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,
36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,6
9
,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100) DO move /-y C:\B\%%A\%%B\%%C\*.* C:\A\%%A\%%B\%%C\

edit: this will only work if the full structure already exists in A (it does not create folders)

Edited by Ponch
Link to comment
Share on other sites

I can't see how files in B would be overwritten here.

@Ponch, actually I said lost, not overwritten. They cannot be overwritten since nothing is being written into B. His plan as he said is "move all the files, along with their folder structure, from B to A, as long as they don't cause any overwriting.". His folder A becomes the fatter one, aka the master, with B becoming skinnier, aka the remainders. Consequently, any files in B which somehow became updated or better than A prior to this merge will be lost during the transaction.

What's the difference with this

Copy B into C

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

?

Not sure what you are asking here. But first note there is no folder C to start with (that was my temp thingie). Also note that I had a (and click YES to all) after that first copy (since he mentioned in Post#5 that the second folder structure is similar so there will likely be a dialog about overwrite, hence the YES to all.). Maybe you are looking for less steps? Looking at it again I see it can be done this way as well ...

Copy folder B to new folder C

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

But it is certainly academic at this point since he has since made clear this is ongoing and thus he really needs to obtain a file sync program (one that allows source delete or file moves).

P.S. it looks like that excellent For Loop you posted should be in a CodeBox instead of Code as it causes that one post to exceed the width of the page. We'll see in a moment how this post goes in (whether it inherits the runoff).

EDIT: yup, just Post#12 exceeded the width. Mods ... I will make a post in the forum issues area about this. I took a look at the HTML and CSS and think I see the problem.

Edited by CharlotteTheHarlot
Link to comment
Share on other sites

Ok, folks,...sorry for

- being confused with different tags use (it looked ok on my preview and I did not check on the normal page)

- writing something that looks prehistoric to Jaclaz. In fact this is the first time I ever write something with the FOR command and I just googled for its use, wrote a few lines batch and tested it. And Charlotte described it as excellent, but I'm not ruling out sarcasm here. :D

Still, Charlotte

I want to move all the files from structure B, to structure A, except the ones that would cause overwriting.

there is nothing even in further posts, that suggests a "more up to date file" in B is OK to overwrite older file in A.

What's the difference with this

Copy B into C

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

...

Looking at it again I see it can be done this way as well ...

Copy folder B to new folder C

Copy A into C (and click YES to all)

Delete Folder A

Rename Folder C to A

This time it's me that can't see the difference, except of course folder C doesn't exist at first and is new. But lets consider my remark as pedantic.

Hoping the OP can get something out of this thread.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...