Paste over, a structure of folders without overwriting files? Is it possible?
#1
Posted 10 November 2009 - 03:42 PM
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.
#2
Posted 10 November 2009 - 04:13 PM
xcopy c:\structure c:\structure_empty /t /e /i
#3
Posted 11 November 2009 - 03:25 AM
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.
#4
Posted 11 November 2009 - 03:33 AM
--
Best Regards,
DreamsCentral
Twitter: @DreamsCentral
Signed: Wednesday, November 11, 2009, 3:03:23 PM IST
#5
Posted 11 November 2009 - 03:45 AM
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].
#6
Posted 11 November 2009 - 04:36 AM
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.
#7
Posted 11 November 2009 - 04:44 AM
http://www.imaginaryplanet.net/weblogs/idi...mer/?p=83398413
Personally I would use a "backup" like app, like robocopy or strarc:
http://www.ltr-data.se/opencode.html
http://www.ltr-data....iles/strarc.txt
jaclaz
#8
Posted 11 November 2009 - 10:18 AM
CharlotteTheHarlot, on Nov 11 2009, 05:36 AM, said:
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.
#10
Posted 14 November 2009 - 05:49 AM
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 ...
horus, on Nov 11 2009, 12:18 PM, said:
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.
This post has been edited by CharlotteTheHarlot: 16 November 2009 - 07:59 AM
#11
Posted 14 November 2009 - 06:28 AM
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.techrep...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.
This post has been edited by horus: 14 November 2009 - 09:52 AM
#12
Posted 14 November 2009 - 12:51 PM
CharlotteTheHarlot, on Nov 14 2009, 12:49 PM, said:
horus, on Nov 11 2009, 12:18 PM, said:
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.
+
CharlotteTheHarlot, on Nov 14 2009, 12:49 PM, said:
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[/color]
?
@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)
This post has been edited by Ponch: 14 November 2009 - 12:56 PM
#13
Posted 15 November 2009 - 04:27 AM
Ponch, on Nov 14 2009, 02:51 PM, said:
@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.
Ponch, on Nov 14 2009, 02:51 PM, said:
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.
This post has been edited by CharlotteTheHarlot: 15 November 2009 - 04:41 AM
#14
Posted 15 November 2009 - 04:46 AM
I am confused by the FOR loop from 1 to 100.
Are we "talking" 2K/XP right?
Wouldn't:
FOR /L %%C IN (1,1,100)
do?
jaclaz
#15
Posted 15 November 2009 - 05:25 AM
- 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.
Still, Charlotte
horus, on Nov 10 2009, 10:42 PM, said:
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.
CharlotteTheHarlot, on Nov 15 2009, 11:27 AM, said:
Ponch, on Nov 14 2009, 02:51 PM, said:
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.
#16
Posted 15 November 2009 - 04:39 PM
ROBOCOPY %SOURCE% %DESTINATION% /E /COPYALL /MOVE /XC /XN /XOObviously you'd need to define both %SOURCE%, (currently B), and %DESTINATION%, (currently A).
#17
Posted 16 November 2009 - 03:43 AM
Ponch, on Nov 15 2009, 12:25 PM, said:
Well, there is googling and googling
http://www.robvanderwoude.com/
http://www.robvander...e.com/ntfor.php
jaclaz
#18
Posted 16 November 2009 - 04:42 AM
Ponch, on Nov 15 2009, 06:25 AM, said:
You're right about that. I was just playing it safe is all (expect the worst hope for the best, etc). My first commandment is to protect the data.
Ponch, on Nov 15 2009, 06:25 AM, said:
LOL ... no sarcasm really! I love FOR loops especially nested ones and that one looks to me like it will work. I just wanted to avoid the multiple dialogs about overwrite.
CharlotteTheHarlot, on Nov 15 2009, 11:27 AM, said:
In that second example I just knocked off one copy operation.
There was definitely nothing elegant or efficient about what I posted, it was merely functional and lossless. When I have a backup present (and I always do myself, but clients never seem to) then I go for beauty and elegance!
@horus, haven't used RichCopy but from that page you posted it sure looks like all the options you will need are in place. If I were you I might just back up that whole folder structure into a ZIP and then experiment away!
#19
Posted 21 November 2009 - 04:18 AM
I've tried RichCopy again, and it seems to work with these settings:

It seems to work(I've tested it on a small number of files), except that it doesn't move files with "~" in their name.
Can someone confirm that it does what I want, before I destroy 20k files?



Help
Back to top









