Copy Tree over existing file(s)

Discuss SolidWorks PDM
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2548
x 1400

Copy Tree over existing file(s)

Unread post by bnemec »

Hello,
We run into this fairly often where we want to copy tree but the destination file already exists. I have not found a way to enable this process. Our current workflow/around is to check out the destination file then open the source file in SW and simply do a Save As.

The work around is ok, but sometimes it would be nice to have consistent instructions instead of "Use copy tree unless the file already exists then check it out and use SW to save as. And if there's component files that are needed then you need to do them in the correct order or they'll reference the wrong thing and if you want the drawing those need to be done first and open when you save as the model...." Copy Tree would just be better.
User avatar
JSculley
Posts: 646
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 9
x 878

Re: Copy Tree over existing file(s)

Unread post by JSculley »

Do you have 'Do not allow duplicate file names' enabled for your vault? If so, this may be the culprit:

SPR: 1111982

SOLIDWORKS PDM: Not possible to overwrite existing file (when renaming copied file to target file name) using Copy Tree if 'Do not allow duplicate file names' is enabled -Copy button is disabled

For what it's worth, I do not have that option enabled in my vault and I took a test assembly and Copy Tree'd it to another directory and then Copy Tree'd the original right over the top of the copy. The Copy Tree dialog warns me about the target files already existing, but the Copy succeeds.
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2548
x 1400

Re: Copy Tree over existing file(s)

Unread post by bnemec »

JSculley wrote: Fri Jan 06, 2023 3:44 pm Do you have 'Do not allow duplicate file names' enabled for your vault? If so, this may be the culprit:

SPR: 1111982

SOLIDWORKS PDM: Not possible to overwrite existing file (when renaming copied file to target file name) using Copy Tree if 'Do not allow duplicate file names' is enabled -Copy button is disabled

For what it's worth, I do not have that option enabled in my vault and I took a test assembly and Copy Tree'd it to another directory and then Copy Tree'd the original right over the top of the copy. The Copy Tree dialog warns me about the target files already existing, but the Copy succeeds.
Yes we do have "Do not allow duplicate file names" enabled. I'm pretty sure we want to keep that checked; there's been quite a few files that users complain "it won't let me check it in". The warning clearly states the file already exists. So I'm sure we'd have all the problems that having duplicate files creates if I unchecked that.

I think I get why this matters from a logic side. But we're not trying to make duplicate files by same name, we're saving a new CAD file as a new version of an existing PDM "Document". That probably sounds shady, I agree it's not something we should be trying to do but the remodel everything in solidworks blitzkrieg left us with many many part files that need redone.

The behavior I was hoping for is Move Tree may warn if the file already exists (which it does in the file ref data grid) but then if the user says go ahead it just creates a new version of the existing file name. Just like the technical comments in the SPR state. The SPR says it is a 2018 regression reproduced in 2018SP3. Also states that what I'm asking for was able to be done in 2017. The SPR is marked as implemented in 2019SP4 which happens to be the version we're running.
Knowledge Base wrote: It is not possible to overwrite an existing file (when renaming copied file to target file name) using Copy Tree if 'Do not allow duplicate file names' is enabled - Copy button is disabled (greyed out) *2018 regression* Reproduced using SWPDM 2018 SP3, SP5, Windows 10
1. Create folder 'A', create a file 'A.txt' with some content. Check in.
2. Create a folder 'B'. Create a file 'B.txt' with some different content. Check in.
3. Enable 'do not allow duplicate names' under file types.
4. Start copy tree on 'A.txt'. Select target folder 'B'. Change target file name to 'B.txt'.
5. The copy button remains greyed out. It is not possible to complete the copy process.
- If you disable 'do not allow duplicate names' - the copy button remains active and you can copy the file and replace the original.
- In 2017 and older versions it was possible to copy and replace existing files even when duplicate name check was enabled.

I just tested the workflow they suggested, except on some test files already in our vault. The copy button is not grayed out and I get the "file already exists" dialogs that I click the overwrite button on. It acts like it's going to work then I get the "Duplicate File Names in Vault" warning dialog:
image.png

Edit: After checking the file I see it was indeed replaced. Move Tree deleted the original and saved a new file. So file history is gone, revision started at 0, and a new PDM DocID. The original file can be found in the Deleted Items dialog. This is not desirable in our use case. I'm not sure why it would ever be useful. Anyone with permissions can simply delete the file(s) before Move Tree if that is desired behavior. But that defeats the purpose of PDM version history of a file. In previous tests I took my user out of admin group to simulate what the user was seeing, so I didn't have permission to delete files and there was no action taken. This time I tested it my user was in admin group, so the Move Tree was able to delete files.
Post Reply