copyfile is not renaming file it creates new sub-folder.
Moderators: Dorian (MJT support), JRL
copyfile is not renaming file it creates new sub-folder.
HI,
I am trying to copy a file into another folder and rename it at the same time. Instead, this creates a sub-folder in the target folder.
Any idea why and how to get around it?
Let>CF_OVERWRITE=1
CopyFile>K:\Installers\_CurrentParts\Install_*.exe,K:\Installers\Project\.exe
Win 7 x 64 running Macro Sched. 11.1.19
thanks,
Bob
I am trying to copy a file into another folder and rename it at the same time. Instead, this creates a sub-folder in the target folder.
Any idea why and how to get around it?
Let>CF_OVERWRITE=1
CopyFile>K:\Installers\_CurrentParts\Install_*.exe,K:\Installers\Project\.exe
Win 7 x 64 running Macro Sched. 11.1.19
thanks,
Bob
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Trying to copy potentially multiple files (*.exe) to one file (.exe) is nonsensical and confusing so Windows thinks you want to move those files (*.exe) to a new subfolder (.exe).
You can't do a copy where the source is potentially many files and the destination is one file.
If the issue is that you don't know what the full name of the source is, and if it is safe to assume there is only one matching file in the source folder you could do:
If there are more than one matching source file this would rename only the first. I'm not sure what you would want to do if there are more than matching source file because they can't all end up with the same name in the same folder!
You can't do a copy where the source is potentially many files and the destination is one file.
If the issue is that you don't know what the full name of the source is, and if it is safe to assume there is only one matching file in the source folder you could do:
Code: Select all
CopyFile>K:\Installers\_CurrentParts\Install_*.exe,K:\Installers\Project\
GetFileList>K:\Installers\Project\Install_*.exe,file_list
Separate>file_list,;,files
If>files_count>0
Renamefile>files_1,K:\Installers\Project\.exe
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi,
I mis-spoke. My intent is a 1 to 1 relationship between source and target files.
My use of the wildcard is accidently qualifying more than one file.
I tried using question marks first (ala DOS) but that had same result. Are there any "placeholder" type wildcards that would only affect one character each?
Bob
I mis-spoke. My intent is a 1 to 1 relationship between source and target files.
My use of the wildcard is accidently qualifying more than one file.
I tried using question marks first (ala DOS) but that had same result. Are there any "placeholder" type wildcards that would only affect one character each?
Bob
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
My answer remains the same. Regardless of the number of wildcard characters a wildcard of any kind has the potential for many files to match. So the solution remains the code in my previous reply.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Marcus,
I believe the issue is my use of wildcards. Do you have a wildcard that works on a single characer, similar to DOS?
Is it still true that he behavior for files is supports multiple wildcards in combination with other text? (if found that elsewhere in the forum)
mydir/r*d*.txt
means there has to be an r and a d and there might be other characters where the *'s are?
It sems as though this
Is ignoring the DPRW part of the source mask and therefor finding more than one source and creating a folder instead of a file.
thanks again, I greatly appreciate your help.
I believe the issue is my use of wildcards. Do you have a wildcard that works on a single characer, similar to DOS?
Is it still true that he behavior for files is supports multiple wildcards in combination with other text? (if found that elsewhere in the forum)
mydir/r*d*.txt
means there has to be an r and a d and there might be other characters where the *'s are?
It sems as though this
Code: Select all
CopyFile>K:\Installers\_CurrentParts\Install*DPRW.exe, k:\installers\projects\InstallDP.exe
thanks again, I greatly appreciate your help.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Install*DPRW.exe will and does find all files which start "Install" and end "DPRW.exe". Which could be one or more files. Wildcards imply the potential for multiple matches regardless of how you use them.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sorry, we both seem to be repeating ourselves. I thought I had answered that. No, there is only the * character which will match any chars.
I have tried to explain several times, that while you may only have one file that matches, the file spec given has the potential to match multiple files. Therefore Windows has to assume that the destination is a folder because you can't copy multiple files to one file (unless you are doing some kind of append which doesn't apply in this case).There is only one file that starts with "Install" and ends with "DPRW", yet I still get a folder created instead of a file copied.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?