| 1. |
Solve : multiple renaming files? |
|
Answer» Can someone help me rename multiple files. If copied.txt exists already, what should happen to it? nothing. copied.txt should stay as it is, but not_copied.txt should rename to copied.txt Quote from: Blisk on December 22, 2018, 06:29:40 AM nothing. Rename will fail because you cannot have two files in a folder with the same name. Quote from: Salmon Trout on December 22, 2018, 07:09:02 AM Rename will fail because you cannot have two files in a folder with the same name.there is no two files in folder with same name, it is only one file.Your original question seeks to do this: Quote d:\myfolder\archive\john\documents\today\not_copied.txt That is, not_copied.txt renamed to copied.txt in that folder. I asked: Quote If copied.txt exists already, what should happen to it? I clearly meant "if d:\myfolder\archive\john\documents\today\copied.txt already exists in that folder, what should happen to it?" One of us is confused, which one? if that file exist than it should leave it if there exist not_copied.txt it should rename it if laso file exist.txt exist.You cannot have 2 files called copied.txt in the same folder. If copied.txt already exists in the same folder, what NEW name should not_copied.txt have? And what if that new name already exists etc? Are these really the names, or just placeholders used in your question? I have a script which looks OK, but I shall not post it here unless you address this. I will soon click "unnotify", so please answer if you want any more help. Quote from: Salmon Trout on December 22, 2018, 07:31:11 AM Your original question seeks to do this:Did they edit their question at some point because I see this. d:\myfolder\archive\nina\documents\exist.txt d:\myfolder\archive\nina\documents\today\not_copied.txt Quote from: Squashman on December 22, 2018, 10:11:06 PM Did they edit their question at some point because I see this. That was not edited; that is not the problem. The requirement appears to be this: Quote d:\myfolder\archive\nina\documents\exist.txt See? Same folder for copied.txt (the desired end result) I guess this could be an error. That is Look in folder $NAME\documents for a file called exists.txt If it is found: Look in folder $NAME\documents\today for a file called not_copied.txt If that is found: Rename it to copied_txt I appear to have set the cat among the pigeons by asking innocently "What happens if copied.txt already exists?". Looking behind the CODE for a moment, I am wondering if the desired end result is to copy or move not_copied.txt to another folder as copied.txt. That is, conceptually, the names copied and not_copied clash with the idea of 'rename'. Copy duplicates a file; rename leaves it in place. The question of what to do if the desired destination file place/name already exists still remains, though. |
|